SDK reference
React
PlayStepProvider, usePlayStep, useTrack and guideAnchor from @axceera/playstep-react.
@axceera/playstep-react is a thin layer over @axceera/playstep. Guides render in PlayStep's own shadow root, never inside your React tree.
PlayStepProvider
Starts PlayStep once and keeps the signed-in user in sync. It renders only its children.
import { PlayStepProvider } from '@axceera/playstep-react'
<PlayStepProvider appKey="ps_pub_prod_your_key" user={user ? { id: user.id, traits: { plan: user.plan } } : null} locale="en">
<App />
</PlayStepProvider>
| Prop | What it does |
|---|---|
appKey | Your publishable key. |
user | { id, traits? } for the signed-in user. Changing it re-identifies; null after sign-out resets the device. Since identify merges traits, a trait that leaves user.traits (or that the next user lacks) is sent as null for you, so it no longer matches segments (0.10+). |
paused | true while this user should not see guides (a guest in this workspace, say): it calls pause(), and resume() when it turns false. Leave it out to pause and resume yourself. |
| other props | Any init option: apiBase, locale, autoPageViews, onEvent, navigate, startPage, config, preview. |
Take users to where a guide starts
Give the provider your router as navigate, and a guide started from the guide list, the finish screen or start() on another page begins on its start page (how it works). Put the provider inside your router, so it can use it. Options are read once, when PlayStep starts, so pass a function that stays valid (React Router's and Next.js's do).
// React Router
function PlayStepRoot({ children }: { children: React.ReactNode }) {
const navigate = useNavigate()
return <PlayStepProvider appKey="ps_pub_prod_your_key" navigate={(path) => navigate(path)}>{children}</PlayStepProvider>
}
// Next.js App Router (a client component)
const router = useRouter()
<PlayStepProvider appKey="ps_pub_prod_your_key" navigate={(path) => router.push(path)}>{children}</PlayStepProvider>
usePlayStep
Returns the SDK: track, start, complete, page, openLauncher, resetProgress, identify, reset, pause, resume and isPaused.
import { usePlayStep } from '@axceera/playstep-react'
function HelpButton() {
const playstep = usePlayStep()
return <button onClick={() => playstep.start('create-first-invoice')}>Show me how</button>
}
openLauncher opens the list of guides people can replay, even with the floating button off, and resetProgress lets guides start again without signing the user out. See Let users replay guides.
function HelpMenu() {
const { openLauncher, resetProgress } = usePlayStep()
return (
<>
<button onClick={(e) => openLauncher({ anchor: e.currentTarget })}>Replay product tours</button>
<button onClick={() => resetProgress()}>Show me the tips again</button>
</>
)
}
useTrack
Reports an event when the component mounts, and again when the event name (or its properties) changes. Pass null to
skip. Properties (SDK 0.10+), as in useTrack('pricing_viewed', { plan }), go to add-ons; guides use the name.
import { useTrack } from '@axceera/playstep-react'
function InvoicesPage() {
useTrack('invoice_page_opened')
return <InvoiceList />
}
guideAnchor
Props that mark an element as an anchor.
import { guideAnchor } from '@axceera/playstep-react'
<button {...guideAnchor('new-invoice-btn')}>New invoice</button>
playstep
The SDK itself, for code outside components:
import { playstep } from '@axceera/playstep-react'
router.afterEach(() => playstep.track('route_changed'))