Almost every move-up seller faces this and there is no universally right answer. There is a right answer for your risk tolerance and your financing, and they pull in opposite directions.
The two orders
Sell first, then buy
You know exactly what you have to spend and you are negotiating from strength. The risk is at the other end: you have a firm closing date and nowhere confirmed to go. In a fast market you can be pushed into compromising on the purchase, or into a rental and two moves.
Buy first, then sell
You secure the home you want and sell without pressure on the timeline. The risk is financial: if your sale comes in below expectation, or does not sell at all, you are carrying two properties. This is the order that ends badly when a market turns.
In a seller's market with low inventory, buying first is the greater risk, because the thing you cannot control is finding a home. In a buyer's market with rising days-on-market, selling first is the greater risk, because the thing you cannot control is your own sale. Read the pocket you are in rather than a general rule, and see Observing the Market.
Bridge financing
A short-term loan that covers the gap when your purchase closes before your sale does. It lets you close on the new home using the equity from a house you have not yet been paid for.
It requires a firm sale. Lenders bridge against an unconditional agreement of purchase and sale, not against a listing or a hope. This is the single most important thing to understand about it.
It is short. Typically up to 90 or 120 days, arranged with the lender funding your new mortgage.
It is not cheap, and it is not ruinous either. Expect a rate meaningfully above prime plus a setup fee, on a balance you carry for weeks rather than years.
Matching the dates
The cleanest outcome is closing your sale and your purchase on the same day, or a few days apart. It takes coordination between two sets of lawyers and two lenders, and it removes the need to bridge at all. Where it is possible, it is worth designing both transactions around.
Making your purchase conditional on selling your own home is the safest structure and the weakest offer. In competition it is close to unusable. Where a seller does accept one, expect an escape clause letting them continue marketing and giving you a short window to firm up if they get another offer.
Before deciding the order, ask your lender two questions: will you bridge for me, and on what conditions. The answer frequently decides the sequence for you.