Docs
Guides for your whole app
One script tag: launcher, buttons and links.
One script tag gives your app a guides launcher, buttons that start a guide, and links that play one on arrival.
<script src="https://cdn.jsdelivr.net/npm/trace-avatar/dist/trace-auto.min.js"
data-guides="/guides/index.json" data-perform="true" defer></script>
<button data-trace-guide="create-invoice">Show me how</button>
<button data-trace-guide="create-invoice" data-trace-mode="perform">Do it for me</button>A small round button in the corner lists the guides for the page the viewer is on. Any element with data-trace-guide="id" starts one, including elements your framework renders later. While a guide plays, the corner button becomes Stop guide. The player is fetched on the first play, so until then the page pays about 5 KB.
The manifest
{
"version": 1,
"guides": [
{ "id": "create-invoice", "title": "Create an invoice", "trace": "create-invoice.trace.json",
"modes": ["overlay", "perform"], "pages": ["/app/invoices", "/app"] }
]
}Trace URLs are relative to the manifest. Without pages a guide is offered on every page. Only guides in the manifest can play, by id. The schema is trace-avatar/guides.schema.json.
Script attributes
| Attribute | Default | |
|---|---|---|
data-guides | — | the manifest URL |
data-launcher | bottom-right | bottom-left, or off to use only your own buttons |
data-perform | false | true allows Do it for me, for guides whose modes include perform (both must agree) |
data-links | on | overlay: links play Show me only; off: links are ignored |
Links
https://your.app/app/invoices?trace=create-invoice opens the page and plays the guide; add &trace-mode=perform for Do it for me, or use #trace=… if your server drops unknown parameters. The launcher has Copy link on every guide, and guides.link(id, { mode, path }) builds one.
- The parameter is removed from the address on arrival, so a reload doesn’t replay it.
- If your prepare hook says the viewer must sign in first, the link waits through the sign-in (even a full page reload) for up to 10 minutes.
- A link can only name a guide id from your manifest, never a trace or a trace URL.
- Do it for me from a link always asks first: “Start · Show me instead · Cancel”.
From npm, with your router
import { mount } from 'trace-avatar/auto';
const guides = mount({
guides: '/guides/index.json',
perform: true,
navigate: (path) => router.push(path),
prepare: async () => isSignedIn(),
launcher: 'bottom-left', // or false
});
guides.play('create-invoice', { mode: 'perform' });
guides.on('error', (e) => console.warn(e.message));The full reference is in the README on GitHub.