supastarter for Next.jsCustomization
Add a new onboarding step
Learn how to adjust the onboarding flow in your supastarter app and add a new step.
The onboarding flow in supastarter is designed to be modular and easily extensible. This guide explains how to add new steps to the onboarding process.
Overview
The onboarding system consists of two main components:
OnboardingForm.tsx
- The container component that manages step navigation- Individual step components (e.g.,
OnboardingStep1.tsx
)
Adding a New Step
1. Create the Step Component
Create a new file for your step component in apps/web/modules/saas/onboarding/components/
. For example, OnboardingStep2.tsx
(you could also name it semantically, e.g. OnboardingStepTeam.tsx
):
2. Update OnboardingForm.tsx
Add your new step to the steps
array in OnboardingForm.tsx
.
3. Add Translations
Add the necessary translations for your step in your translation files:
Best Practices
-
State Management
- Use the
onCompleted
prop to handle navigation between steps - For the final step, call the main
onCompleted
function to finish onboarding
- Use the
-
Form Validation
- Always use Zod schemas for form validation
- Include proper error handling and error messages
-
UI Components
- Use Shadcn UI components for consistency
- Follow the existing pattern of using
Form
,FormField
,FormItem
, etc.
-
Responsive Design
- Ensure your step component works well on both mobile and desktop
- Use Tailwind's responsive classes when needed
-
Progress Indicator
- The progress bar will automatically update based on the number of steps in the
steps
array
- The progress bar will automatically update based on the number of steps in the
Example Flow
- User starts at step 1 (
?step=1
) - After completing step 1, they're moved to step 2 (
?step=2
) - After completing the final step, they're redirected to the app dashboard
Notes
- The onboarding state is tracked in the URL using the
step
query parameter - If you want to make the process more robust, you could add a
onboardingStep
cookie to track the step in case the user navigates away from the page and comes back later. - The final
onCompleted
function updates the user'sonboardingComplete
status and redirects to the app - Each step component should be a client component (use "use client" directive)