Preserving booking flow state across Supabase email auth redirect (Next.js)
here’s a cleaned-up question you can drop into the Supabase Discord:
I’m building a booking app (Next.js 14 + Supabase). Users can complete the booking steps as guests, but on the final step they must authenticate. I trigger email OTP and redirect back to my app after the user clicks the link.
Current flow
1. User completes steps 1–3 (guest). 2. At step 4 (payment), I call
signInWithOtp
signInWithOtp
and pass an
emailRedirectTo
emailRedirectTo
URL that brings them back to
/auth/callback
/auth/callback
. 3. The session is created, but my app sends them back to the main homepage. Not the booking step with state
What I want After the email link flow, the user should land back on the booking flow with all prior steps preserved and be taken straight to the payment page.
Question What’s the recommended way to persist and restore pre-auth state across the Supabase email link redirect?
* Should I encode a
state
state
/
next
next
param in
emailRedirectTo
emailRedirectTo
and restore from that? * Is there a built-in “state” mechanism for email OTP similar to OAuth, or should I roll my own? * Best practice to link an anonymous/guest booking to the newly authenticated user (e.g., stash a
bookingId
bookingId
+ secure token server-side and attach it post-auth)? * Any examples using Supabase Auth Helpers for Next.js to keep session continuity and avoid restarting the flow?
Appreciate any patterns or example repos that show resuming a multi-step flow after magic-link auth.
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.