useFirstflow() returns the current runtime state and the methods to drive it. Use it to trigger experiences from your own UI, build a custom shell, or react to the active step. It must be called inside FirstflowProvider.
State
The running experience and its position (
experience, currentNodeId,
history, answers), or null when nothing is showing.The resolved user your
user, or the anonymous fallback.Auto-tracked session context (
url, locale, deviceType, startedAt) used
by audience conditions.The compiled experiences the provider loaded.
Methods
Start an experience by id (bypasses triggers). No-op if the id is unknown.
Advance the active run to the next visible node, optionally recording an answer.
End the active run and record it dismissed.
Fire a custom event triggers any experience with a matching
custom_event trigger. The standalone emitCustomEvent(name) does the same
from outside the provider.Run a single compiled action (
next, submit, dismiss, link, event,
prompt, minimize). Used by the default blocks.Run an ordered list of actions for one interaction. Non-terminal actions
(
link/event/prompt/minimize) run in author order; the single terminal
action (next/submit/dismiss) runs last.Collapse the widget shell to its resting state without ending the run.
Register a collapse handler so the
minimize action can reach a custom shell.
Returns an unregister function.Persistence interface
Pass any object implementingFirstflowPersistence to the provider. Implement it for a non-Supabase backend:
loadInProgress runs once on mount (for resume); recordProgress fires on every transition; recordEnd fires on completion or dismissal. All writes are fire-and-forget failures are logged, never thrown.
Custom launcher with events
Next
Build a custom shell, handle events, or wire the server SDK classifier to driveemit.