# FAQ

> Short answers to what Vue and Nuxt developers ask most about Stepperize.

Framework: Vue (`@stepperize/vue`), Stepperize v9.
Source: https://stepperize.com/docs/v9/vue/faq

## Is Stepperize a form library?

No. It manages the **flow**: which step is current, moving between steps, what
each step saved and which steps are complete. Field state (values while
typing, touched, field errors) belongs to `v-model`, your form library or a
few lines of your own. See [Forms](https://stepperize.com/docs/v9/vue/guides/forms).

## Does it ship any styles or markup?

No styles. `useStepper()` gives you state and you write all the markup. The
optional [`Stepper` primitives](https://stepperize.com/docs/v9/vue/guides/primitives) add
accessible, unstyled elements that you style through data attributes.

## Do I need @stepperize/core?

Not in a Vue app: `@stepperize/vue` installs it and re-exports its types.
Import from it directly to run a flow [without Vue](https://stepperize.com/docs/v9/core), for
example in a test or on a server.

## When should I use Provider, Stepper.Root or plain useStepper?

- **`useStepper()`** when one component renders the whole flow.
- **`Provider`** when several components need the same flow.
- **`Stepper.Root`** when you use the primitives. It is a provider too.

Components below a `Provider` or a `Stepper.Root` read the flow with
`useStepperContext()`. See [Shared state](https://stepperize.com/docs/v9/vue/guides/shared-state).

## Why is there no .value on the stepper?

The stepper is not a ref. It is a reactive, read-only object, like a
`reactive()` object or a Pinia store: templates, `computed` and getters track
what they read from it. Two things do return refs: `useStepperContext()` with
a selector and `Stepper.useItem()` return a `ComputedRef`, so read `.value` in
the script.

```ts
const stepper = checkout.useStepper();
stepper.current.id; // no .value

const isLast = checkout.useStepperContext((s) => s.isLast);
isLast.value; // a ComputedRef<boolean>
```

## How do I run code when the step changes?

Watch a getter of what you need, such as `() => stepper.current.id`.
`watch(stepper, ...)` never runs, because the stepper is not a watch source.
To see every change of the flow, data included, use the `onChange` option.

```ts
const stepper = checkout.useStepper();

watch(
  () => stepper.current.id,
  (id) => analytics.track("step", { id }),
);
```

## Can I bind v-model to a step's data?

Not to `stepper.data` itself: writing into it changes the flow's object
without telling the flow, so nothing re-renders and `onChange` does not run.
Keep the fields in your own `reactive()` and pass a copy to `next()`, as in
[Forms](https://stepperize.com/docs/v9/vue/guides/forms#validate-on-continue). To keep the draft in
the flow as the user types, bind a writable `computed` that writes with
`setData`:

```vue
<script setup lang="ts">
import { computed } from "vue";
import { checkout } from "./checkout";

const stepper = checkout.useStepper();

const address = computed({
  get: () => stepper.data.shipping?.address ?? "",
  set: (address) => stepper.setData("shipping", { address }),
});
</script>

<template>
  <input v-model="address" aria-label="Address" />
</template>
```

## How do I validate a step before moving on?

Put a `schema` on the step. `next()` validates it and stays on the step when
it fails; `stepper.issues()` holds the reasons. See
[Schemas and validation](https://stepperize.com/docs/v9/vue/guides/validation): the options are
the same in Vue.

```ts
const signup = defineStepper([
  { id: "account", schema: z.object({ email: z.email() }) },
  { id: "done" },
]);
```

## What do next, prev and goTo return?

A promise of a result: `{ accepted: true, to, data }` or
`{ accepted: false, reason, issues? }`. They do not throw for an expected
outcome. The stepper is live, so after `await stepper.next()` it already
shows the new step. See
[Moving between steps](https://stepperize.com/docs/v9/vue/guides/navigation#read-the-result).

## How do I handle the final submit?

Call `next()` on the last step. It finishes the flow and calls `onFinish` once
with the validated output of every complete step. `stepper.isLast` tells you
when to change the button's label, and `stepper.isFinished` when to show the
confirmation. If the request can fail, return its promise from `onFinish`; see
[Finish the flow](https://stepperize.com/docs/v9/vue/guides/navigation#finish-the-flow).

## Where are the values my schema transformed?

In `stepper.output`, and in the first argument of `onFinish`. `stepper.data`
keeps what was typed. See
[Draft data and validated output](https://stepperize.com/docs/v9/vue/guides/validation#draft-data-and-validated-output).

## How do I keep the current step in the URL?

Pass the options as a getter with `step: route.params.step`, and push the new
step from `onChange`. It works with Vue Router and Nuxt pages. See
[The route as the current step](https://stepperize.com/docs/v9/vue/guides/url).

## How do I save progress and resume later?

Save the snapshot `onChange` gives you, and pass it back as `snapshot`. In
Nuxt, a cookie lets the server render the saved step; see
[Resuming from a cookie](https://stepperize.com/docs/v9/vue/guides/ssr#resuming-from-a-cookie-or-the-database)
and [Saving and resuming](https://stepperize.com/docs/v9/vue/guides/persistence).

## Can a Pinia store own the flow?

Yes. Call `useStepper()` in a setup store: the store keeps the stepper as it
is, actions and all. The flow then lives as long as the store, not as long as
a page, so it keeps its step when the user leaves and comes back. It is not
part of the store's `state`: persist it with `onChange` and `snapshot`. Read it
as `store.stepper`; `storeToRefs()` leaves it out, because it is not a ref.
See [In a Pinia store](https://stepperize.com/docs/v9/vue/guides/shared-state#in-a-pinia-store).

## What happens to the flow under KeepAlive?

A cached component keeps its flow, so the user comes back to the step they
left. While it is not on screen it stops following the `step` option, so it
never rewrites another page's URL; when it is shown again it follows the
current value. To start fresh on every visit, leave the component out of the
cache with the `exclude` prop of `KeepAlive`.

## Can I animate the change of step?

Yes, with Vue's `Transition` component. With the primitives, wrap one keyed
`Stepper.Content`, or give each panel its own `Transition`; focus and the
announcement are handled in every mode. See
[Animating panels](https://stepperize.com/docs/v9/vue/guides/primitives#animating-panels). With
your own markup, key the panel by `stepper.current.id`.

## Can I use a flow outside a component?

Yes. `useStepper()` works inside an `effectScope()`, which destroys the flow
when you stop it, and `checkout.create()` returns the same state machine with
no Vue at all. Called with neither a component nor a scope, the flow is never
destroyed, and in development Stepperize warns
([SZ104](https://stepperize.com/docs/v9/core/errors#sz104)).

```ts
const scope = effectScope();
const stepper = scope.run(() => checkout.useStepper())!;

// Later: destroys the flow.
scope.stop();
```

## Can a flow skip steps or have more than one ending?

Yes. The `next` option decides where each step leads from its data, and a
`null` entry ends the flow at that step. See
[Branching](https://stepperize.com/docs/v9/vue/guides/branching).

## Can the same step appear twice?

No. Ids are unique: they are the key for the data, the completion and the
primitives. A repeated id throws [SZ103](https://stepperize.com/docs/v9/core/errors#sz103) when the
first flow is created. To revisit a step, go back to it.

## How do I reset the whole flow?

`stepper.reset()` returns to the snapshot the flow started with and clears
everything else. To keep the data and only go back to the start, use
`stepper.restore({ step: "shipping", history: [] })`.

## Does it work with Nuxt and server rendering?

Yes, with no configuration. The composables and the primitives render the
current step on the server and hydrate without changing the HTML. No callback
runs on the server: `onChange`, `onFinish`, `onInvalidStep` and the `guard`
only run in the browser. See [Server rendering](https://stepperize.com/docs/v9/vue/guides/ssr).

## Can I leave the components out of my bundle?

Yes. Import `defineStepper` from `@stepperize/vue/headless`. The definition is
the same, without the `Stepper` primitives. See
[Composables without the components](https://stepperize.com/docs/v9/vue/installation#composables-without-the-components).

## Which Vue versions are supported?

Vue 3.5.4 or newer, and any Nuxt version that runs on it. The primitives use
Vue's `useId` for ids that match between the server and the client. Vue 2 is
not supported. See [Requirements](https://stepperize.com/docs/v9/vue/installation#requirements).

## Does it work without TypeScript?

Yes, but the typed ids, the typed data, the checked `step` props in templates
and the exhaustive `match` are most of what you gain.

## I used an earlier @stepperize/vue. Is there a migration path?

The v9 binding replaces the earlier API with the design every binding now
shares, with no compatibility layer; the codemod only rewrites React code.
[Migrating from v8](https://stepperize.com/docs/v9/react/migration) explains what changed in that
design: `next()` validates, one snapshot replaces the controlled props, and one
state per step replaces status and completion.
