There is no "official residency" procedure in a state, so this is determined by your intentions and actions. If you moved to a new state, without the intention of returning to the old state, and took multiple actions indicating you intended to permanently reside in the new state, you could be a resident while in temporary housing. Examples of things which would indicate a permanent move - seeking and putting a contract on a home, listing your old home for sale or giving up your old rented home, getting a driver's license and registering to vote in the new state. There's no specific definition, though, it's more a "I'll know it when I see it" situation.
You become a legal resident of your new state when you establish your new domicile - that is, when you begin living in your new permanent home in the new state.
Your domicile is the place where you maintain a permanent home. Your intent to remain in this place indefinitely makes it your domicile