There are risks both ways and my answer would depend on knowing a lot more about you, your goals, your market and risk tolerance.
If you sell first, you would need to move twice, once to temporary housing and then to your final purchase. The advantage is you can be less stressed about timing and be confident in what you have to work with for your purchase.
If you do buy first, you can empty your home out, have it available for showings without scheduling appointments, needing to leave on short notice and keep it show ready all the time.
Finding a very experienced and successful agent in your area can help you work through the variables and create a strategy that makes sense. It's never too early to start the conversation.