Skip to content

Wizard forms in remix using session storage

License

Notifications You must be signed in to change notification settings

machour/remix-wizard

 
 

Repository files navigation

remix-wizard 🧙‍♂️

A all-in-one solution for building wizards in remix.run

Installation

yarn add remix-wizard

Examples

  1. Create a wizard and specify your routes

oboarding.server.ts

export const onboardingWizard = createWizard({
  name: 'onboarding-wizard',
  routes: [
	'/onboarding/org',
	'/onboarding/users',
	'/onboaring/finish'
  ],
});
  1. Import your wizard and call register in your action

routes/onboarding/users.tsx

import { onboardingWizard } from './onboarding.server'

export const action = ({ request }) => {
    const { save, nextStep, jumpToStep, prevStep } =
      await onboardingWizard.register(request);

    // Save arbitary data to the wizard session
    save('userProfile', { name: 'John Doe' });

    // Jump to a specific step
    if (request.url.searchParams.get('skip')){
      // You can do it by string
      return jumpToStep("/onboarding/finish");

      // Or by index
      // return jumpToStep(3);
    }

    // Go to the next step
    return nextStep();

}
  1. Call register in your loader to access previously stored data
export const loader = async ({ request }) => {
    const { data } = await onboardingWizard.register(request);

    return data?.['userProfile'] || {};
};

About

Wizard forms in remix using session storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • TypeScript 85.1%
  • JavaScript 14.9%