Next.js Discord

Discord Forum

Setup Next.js Route Guard to redirect users if they haven't completed wizard

Unanswered
Silky ant posted this in #help-forum
Open in Discord
Silky antOP
Context: I'm designing the front-end of an onboarding wizard where the user must complete 4 steps:

1. Creating an organization
2. Invite members to this organization (optional)
3. Choose a plan (paid)
4. Enter payment information

Problem:
Currently, the user can "interrupt" this wizard and navigate to any other pages or links on the website. What can Next.js do for the /onboarding route to make sure the user can't navigate until they've completed all 4 steps?

6 Replies

@!=tgt set something on the backend
Silky antOP
Hmm unfortunately, I don't work on the backend.

Right now I'm setting a condition that redirects the user if (!orgs) no orgs exist.

How would I use the middleware to do redirection?