This quickstart adds Trace to a SolidJS or SolidStart app with @trace-id/sdk-solid. You wrap the app in a provider once, read signals in a component, and send the eventId to your backend for verification.
Before you start
You need a running Trace server and a public key (pk_...) whose allowed origins include your app. The quick start guide covers both.
- 1
Install the SDK
npm install @trace-id/sdk-solidpnpm add @trace-id/sdk-solidyarn add @trace-id/sdk-solidbun add @trace-id/sdk-solid - 2
Add the provider
TSX// src/index.tsx import { render } from 'solid-js/web'; import { IdentifyProvider } from '@trace-id/sdk-solid'; import App from './App'; render( () => ( <IdentifyProvider apiKey={import.meta.env.VITE_TRACE_PUBLIC_KEY} endpoint={import.meta.env.VITE_TRACE_ENDPOINT}> <App /> </IdentifyProvider> ), document.getElementById('root')!, );In SolidStart, put the provider in
app.tsx. Nothing runs during server rendering; collection starts in the browser. - 3
Identify on submit
createVisitorDatareturnsdata,errorandisLoadingas signals, andgetData()to identify on demand. Call it in a component body.TSX// SignupForm.tsx import { createSignal } from 'solid-js'; import { createVisitorData } from '@trace-id/sdk-solid'; export function SignupForm() { const [email, setEmail] = createSignal(''); const visitor = createVisitorData({ immediate: false }); async function submit(e: SubmitEvent) { e.preventDefault(); const result = await visitor.getData({ tags: { action: 'signup' } }); // null if Trace is unavailable await fetch('/api/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email(), eventId: result?.eventId }), }); } return ( <form onSubmit={submit}> <input type="email" required value={email()} onInput={(e) => setEmail(e.currentTarget.value)} /> <button disabled={visitor.isLoading()}>Create account</button> </form> ); }getDatanever throws. On failure it resolvesnullanderror()holds anIdentifyErrorwith acode. UseuseIdentifyClient()for consent toggles (enable(),disable(true)). - 4
Verify on your server