---
url: /guide/getting-started.md
description: Get up and running with the WizardKit framework in minutes
---

# Getting Started with WizardKit

This guide will help you get up and running with the WizardKit framework in minutes.

## Installation

Pick your framework. The choice applies to every example on this site and is remembered.

::: code-group

```bash [npm]
npm install @wizardkit/core @wizardkit/react
```

```bash [pnpm]
pnpm add @wizardkit/core @wizardkit/react
```

```bash [yarn]
yarn add @wizardkit/core @wizardkit/react
```

```bash [bun]
bun add @wizardkit/core @wizardkit/react
```

:::

::: code-group

```bash [npm]
npm install @wizardkit/core @wizardkit/vue
```

```bash [pnpm]
pnpm add @wizardkit/core @wizardkit/vue
```

```bash [yarn]
yarn add @wizardkit/core @wizardkit/vue
```

```bash [bun]
bun add @wizardkit/core @wizardkit/vue
```

:::

::: code-group

```bash [npm]
npm install @wizardkit/core @wizardkit/svelte
```

```bash [pnpm]
pnpm add @wizardkit/core @wizardkit/svelte
```

```bash [yarn]
yarn add @wizardkit/core @wizardkit/svelte
```

```bash [bun]
bun add @wizardkit/core @wizardkit/svelte
```

:::

::: code-group

```bash [npm]
npm install @wizardkit/core @wizardkit/solid
```

```bash [pnpm]
pnpm add @wizardkit/core @wizardkit/solid
```

```bash [yarn]
yarn add @wizardkit/core @wizardkit/solid
```

```bash [bun]
bun add @wizardkit/core @wizardkit/solid
```

:::

## Core vs Framework Integrations

* **`@wizardkit/core`**: Framework-agnostic state machine. Use this if you're building a wizard in vanilla TypeScript or any other framework without a dedicated binding.
* **`@wizardkit/react`**: React-specific integration with the `useWizard()` hook. Use this for React applications.
* **`@wizardkit/vue`**: Vue 3 Composition API integration. Use this for Vue applications.
* **`@wizardkit/svelte`**: Svelte integration — `createWizardStore()` on the main entry (Svelte 4 + 5) and a Svelte 5 runes API on `@wizardkit/svelte/runes`.
* **`@wizardkit/solid`**: Solid.js 1.x integration — `createWizard()` with signal-backed reactive getters, `field()` and `WizardProvider`.

## Your First Wizard

A wizard has two parts: a **definition** that describes the steps, and a **binding** that connects it to your UI.

### 1. Define the steps

The definition is plain TypeScript and is the same for every framework.

```ts [wizard.ts]
import { createLinearWizard } from "@wizardkit/core";

export type FormData = {
  name: string;
  email: string;
};

export const wizard = createLinearWizard<FormData>({
  id: "simple-form",
  steps: [
    {
      id: "personal",
      title: "Personal Info",
      validate: async (data) => ({
        valid: Boolean(data.name),
        errors: !data.name ? { name: "Name is required" } : undefined,
      }),
    },
    {
      id: "contact",
      title: "Contact Info",
      validate: async (data) => ({
        valid: Boolean(data.email),
        errors: !data.email ? { email: "Email is required" } : undefined,
      }),
      onSubmit: async (data) => {
        // Handle submission
        console.log("Form submitted:", data);
      },
    },
  ],
  onComplete: async (data) => {
    console.log("Wizard completed!", data);
  },
});
```

### 2. Render it

`useWizard()` returns the wizard state grouped into slices: `state`, `navigation`, `actions`, `validation` and `loading`.

```tsx [MyForm.tsx]
import { useWizard } from "@wizardkit/react";
import { wizard } from "./wizard";

export function MyForm() {
  const { state, navigation, actions, validation, loading } = useWizard({
    definition: wizard,
    initialData: { name: "", email: "" },
  });

  return (
    <div>
      <h2>{state.currentStep.meta?.title}</h2>

      {state.currentStepId === "personal" && (
        <input
          placeholder="Name"
          value={state.data.name}
          onChange={(e) => actions.updateField("name", e.target.value)}
        />
      )}

      {state.currentStepId === "contact" && (
        <input
          placeholder="Email"
          value={state.data.email}
          onChange={(e) => actions.updateField("email", e.target.value)}
        />
      )}

      {validation.validationErrors && (
        <div className="errors">
          {Object.entries(validation.validationErrors).map(([field, error]) => (
            <p key={field}>{error}</p>
          ))}
        </div>
      )}

      <div className="controls">
        <button
          onClick={() => navigation.goPrevious()}
          disabled={!navigation.canGoPrevious || loading.isNavigating}
        >
          Previous
        </button>
        <button
          onClick={() => navigation.goNext()}
          disabled={loading.isNavigating}
        >
          {/* On the last step goNext() completes the wizard; canGoNext is false there. */}
          {navigation.isLastStep ? "Complete" : "Next"}
        </button>
      </div>
    </div>
  );
}
```

More in the [React integration guide](./react-integration).

`useWizard()` returns the wizard state grouped into slices of computed refs: `state`, `navigation`, `actions`, `validation` and `loading`. `useWizardField()` gives you a writable ref for `v-model`.

```vue [MyForm.vue]
<script setup lang="ts">
import { useWizard, useWizardField } from "@wizardkit/vue";
import { type FormData, wizard as definition } from "./wizard";

const wizard = useWizard<FormData>({
  definition,
  initialData: { name: "", email: "" },
});

const { state, navigation, validation, loading } = wizard;

const name = useWizardField(wizard, "name");
const email = useWizardField(wizard, "email");
</script>

<template>
  <div>
    <h2>{{ state.currentStep.value?.meta?.title }}</h2>

    <input
      v-if="state.currentStepId.value === 'personal'"
      v-model="name"
      placeholder="Name"
    />

    <input
      v-if="state.currentStepId.value === 'contact'"
      v-model="email"
      placeholder="Email"
    />

    <div v-if="validation.validationErrors.value" class="errors">
      <p
        v-for="(error, field) in validation.validationErrors.value"
        :key="field"
      >
        {{ error }}
      </p>
    </div>

    <button
      @click="navigation.goPrevious()"
      :disabled="!navigation.canGoPrevious.value || loading.isNavigating.value"
    >
      Previous
    </button>
    <button
      @click="navigation.goNext()"
      :disabled="loading.isNavigating.value"
    >
      <!-- On the last step goNext() completes the wizard; canGoNext is false there. -->
      {{ navigation.isLastStep.value ? "Complete" : "Next" }}
    </button>
  </div>
</template>
```

More in the [Vue integration guide](./vue-integration).

`createWizardStore()` returns a Svelte store, so `$wizard` works in templates. `wizard.field()` gives you a writable store for `bind:value`. On Svelte 5 you can use the runes API from `@wizardkit/svelte/runes` instead.

```svelte [MyForm.svelte]
<script lang="ts">
  import { createWizardStore } from "@wizardkit/svelte";
  import { type FormData, wizard as definition } from "./wizard";

  const wizard = createWizardStore<FormData>({
    definition,
    initialData: { name: "", email: "" },
  });

  // Field stores must be declared at the top level of <script> for `$name` to work.
  const name = wizard.field("name");
  const email = wizard.field("email");
</script>

<h2>{$wizard.currentStep.meta?.title}</h2>

{#if $wizard.currentStepId === "personal"}
  <input bind:value={$name} placeholder="Name" />
{:else if $wizard.currentStepId === "contact"}
  <input bind:value={$email} placeholder="Email" />
{/if}

{#if $wizard.validationErrors}
  <div class="errors">
    {#each Object.values($wizard.validationErrors) as error}
      <p>{error}</p>
    {/each}
  </div>
{/if}

<button onclick={wizard.goPrevious} disabled={!$wizard.canGoPrevious}>
  Previous
</button>
<!-- On the last step goNext() completes the wizard; canGoNext is false there. -->
<button onclick={wizard.goNext} disabled={$wizard.isNavigating}>
  {$wizard.progress.isLastStep ? "Complete" : "Next"}
</button>
```

Svelte 4 users write `on:click={wizard.goNext}` instead of `onclick=`. More in the [Svelte integration guide](./svelte-integration).

`createWizard()` returns an object whose properties are reactive getters: read them in JSX and Solid tracks exactly what you touched. `wizard.field()` gives you a two-way binding for one field.

```tsx [MyForm.tsx]
import { createWizard } from "@wizardkit/solid";
import { For, Match, Show, Switch } from "solid-js";
import { wizard as definition } from "./wizard";

export function MyForm() {
  const wizard = createWizard({
    definition,
    initialData: { name: "", email: "" },
  });
  const name = wizard.field("name");
  const email = wizard.field("email");

  return (
    <div>
      <h2>{wizard.currentStep.meta?.title}</h2>

      <Switch>
        <Match when={wizard.currentStepId === "personal"}>
          <input
            placeholder="Name"
            value={name.value}
            onInput={(e) => (name.value = e.currentTarget.value)}
          />
        </Match>
        <Match when={wizard.currentStepId === "contact"}>
          <input
            placeholder="Email"
            value={email.value}
            onInput={(e) => (email.value = e.currentTarget.value)}
          />
        </Match>
      </Switch>

      <Show when={wizard.validationErrors}>
        {(errors) => (
          <div class="errors">
            <For each={Object.values(errors())}>{(error) => <p>{error}</p>}</For>
          </div>
        )}
      </Show>

      <button
        onClick={() => void wizard.goPrevious().catch(() => {})}
        disabled={!wizard.canGoPrevious}
      >
        Previous
      </button>
      {/* On the last step goNext() completes the wizard; canGoNext is false there. */}
      <button
        onClick={() => void wizard.goNext().catch(() => {})}
        disabled={wizard.isNavigating}
      >
        {wizard.isLastStep ? "Complete" : "Next"}
      </button>
    </div>
  );
}
```

More in the [Solid integration guide](./solid-integration).

## Without a Framework

No binding for your stack? Use `@wizardkit/core` directly:

```typescript
import { WizardMachine, createLinearWizard } from "@wizardkit/core";

type FormData = {
  name: string;
  email: string;
};

const wizard = createLinearWizard<FormData>({
  id: "simple-form",
  steps: [
    {
      id: "personal",
      title: "Personal Info",
      validate: async (data) => ({
        valid: Boolean(data.name),
        errors: !data.name ? { name: "Name is required" } : undefined,
      }),
    },
    {
      id: "contact",
      title: "Contact Info",
      validate: async (data) => ({
        valid: Boolean(data.email),
        errors: !data.email ? { email: "Email is required" } : undefined,
      }),
    },
  ],
  onComplete: async (data) => {
    console.log("Wizard completed!", data);
  },
});

// Create a state machine instance
const machine = new WizardMachine(
  wizard,
  {},
  { name: "", email: "" },
  {
    onStateChange: (state) => {
      console.log("Current step:", state.currentStepId);
      console.log("Data:", state.data);
    },
    onComplete: (data) => {
      console.log("Complete:", data);
    },
  },
);

// Navigate
await machine.goNext();
await machine.validate();
await machine.submit();
```

## Key Concepts (Quick Overview)

* **WizardDefinition**: A declarative description of your entire wizard
* **Steps**: Individual pages/forms in your wizard with validation and transitions
* **Transitions**: How to navigate between steps (static, conditional, or dynamic)
* **Validation**: Field-level rules that must pass before moving forward
* **Context**: A way to pass utilities (API client, logger, etc.) to validators and hooks

Learn more about these in the [Core Concepts](./core-concepts) guide.

## Next Steps

1. Read [Core Concepts](./core-concepts) to understand the framework better
2. Explore [Defining Wizards](./defining-wizards) to learn about different definition patterns
3. Check the integration guide for your framework: [React](./react-integration), [Vue](./vue-integration), [Svelte](./svelte-integration) or [Solid](./solid-integration)
4. Review [API Reference](./api/core) for detailed type information

## Common Questions

**Q: Do I need React?**
A: No! `@wizardkit/core` works with any JavaScript/TypeScript codebase. The React, Vue, Svelte and Solid packages are thin bindings on top of it.

**Q: Can I use this with form libraries?**
A: Yes! The wizard is agnostic to your form library. You can use it with React Hook Form, Formik, plain React state, or anything else.

**Q: How do I handle async validation?**
A: Validators return `SyncOrAsync<ValidationResult>`, so they support both sync and async operations.

**Q: What about complex branching logic?**
A: Use conditional transitions or resolver transitions. See [Core Concepts](./core-concepts) for details.
