FAQ
Short answers to what Vue and Nuxt developers ask most about Stepperize.
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.
Does it ship any styles or markup?
No styles. useStepper() gives you state and you write all the markup. The
optional Stepper 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, 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.Providerwhen several components need the same flow.Stepper.Rootwhen 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.
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.
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.
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. To keep the draft in
the flow as the user types, bind a writable computed that writes with
setData:
<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: the options are
the same in Vue.
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.
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.
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.
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.
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
and Saving and resuming.
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.
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. 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).
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.
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 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.
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.
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.
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 explains what changed in that
design: next() validates, one snapshot replaces the controlled props, and one
state per step replaces status and completion.
Last updated on