Install
Three-step SDK onboarding card with framework tabs, package manager switcher, syntax-highlighted snippets, copy buttons, and inline API key generation.
import { InstallSnippet } from '@uthereal/ui/install-snippet'Install snippet playground
Get started in 30 seconds
Three steps to your first event.
Install
Add the SDK to your projectnpm install @lumen/nextAdd your key
Create a project key.env.localNEXT_PUBLIC_LUMEN_KEY=YOUR_API_KEYShip
Deploy and watch events arriveapp/layout.tsximport { Lumen } from "@lumen/next"; export default function RootLayout({ children }) { return ( <html lang="en"> <body>{children}<Lumen /></body> </html> );}
Overview
InstallSnippet guides developers from package installation to their first event in one self-contained card. Framework tabs (Next.js, React, Vue, and HTML with built-in marks by default) switch three numbered steps (Install, Add your key, and Ship) whose code blocks crossfade inside height-reserved containers with zero layout shift. Step 1 adapts automatically between a package manager switcher (npm, pnpm, yarn, bun) and a CDN script snippet. Clicking Generate key eases the {{key}} slot to the new key width in ch units and wipes the key into place.
Use InstallSnippet for post-signup quickstarts, empty-state dashboards awaiting a first event, and developer documentation landing pages. For a single standalone code block without onboarding steps, use Code. For managing multiple existing provider credentials, use Keys.
Usage
'use client'
import { InstallSnippet } from '@uthereal/ui/install-snippet'
export function SdkOnboarding() {
return (
<InstallSnippet
generateKey={async (signal) => {
const res = await fetch('/api/keys', { method: 'POST', signal })
if (!res.ok) throw new Error('Could not create a key')
const data = (await res.json()) as { key: string }
return data.key
}}
onCopy={(step, value) => {
console.info('Copied onboarding step', step, value.length)
}}
/>
)
}Omit frameworks and generateKey to render the default four-framework sample SDK with a client-side simulated key generator (nothing is sent over the network).
Examples
Signed-in key and preferred package manager
Pass apiKey when the signed-in reader already has a publishable key. The snippets render the key immediately and hide the Generate key button. Set defaultPackageManager to start on a preferred CLI such as pnpm.
Get started in 30 seconds
Three steps to your first event.
Install
Add the SDK to your projectpnpm add @lumen/nextAdd your key
Key created.env.localNEXT_PUBLIC_LUMEN_KEY=lmn_pub_7f3a9c2e4b8d1056Ship
Deploy and watch events arriveapp/layout.tsximport { Lumen } from "@lumen/next"; export default function RootLayout({ children }) { return ( <html lang="en"> <body>{children}<Lumen /></body> </html> );}
Custom frameworks and hidden version
Replace frameworks with your own SDK tabs. Any framework ID outside next, react, vue, and html renders a clean text-only tab, and passing version={null} hides the version label in the header.
Install Beacon SDK
Capture server traces with zero agent overhead.
Install
Add the SDK to your projectbun add @beacon/nodeAdd your key
Create a project key.envBEACON_WRITE_KEY=YOUR_API_KEYShip
Deploy and watch events arrivesrc/telemetry.tsimport { createBeacon } from "@beacon/node"; export const beacon = createBeacon({ apiKey: process.env.BEACON_WRITE_KEY ?? "YOUR_API_KEY", service: "billing-api",}); beacon.track("server.started");
Steps and key generation
Each step circle shows its step number and morphs into a check mark once completed.
| Step | Title | Header control | Completion trigger |
|---|---|---|---|
1 | Install | Package manager tabs or CDN filename | User copies the install command or CDN tag |
2 | Add your key | Config filename + Generate key button | User generates a key, or copies the line once a key is ready |
3 | Ship | Entry filename with line-numbered code | User copies the initialization snippet |
- Placeholder token: Place
{{key}}anywhere inside step snippets. Until an API key exists,keyPlaceholderrenders in an accent-tinted monospace slot and copies verbatim. - Live vs. simulated generation: Supply
generateKey(signal)to call your key endpoint; rejections display an inline error message and switch the button to Try again. In-flight requests abort automatically on unmount or when a new request starts. WhengenerateKeyis omitted, the card generates a local simulated key and announces that nothing was sent.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Get started in 30 seconds" | Card heading text and accessible section name. |
description | stringDefault: "Three steps to your first event." | One-line subtitle under the title. Set to an empty string (or null in React) to hide it. |
version | string | nullDefault: "v2.4.0" | Muted monospace label at the top-end corner, such as an SDK version. Pass null or an empty string to hide it. |
frameworks | InstallSnippetFramework[]Default: [{"id":"next","label":"Next.js","install":{"packages":"@lumen/next"},"key":{"file":".env.local","code":"NEXT_PUBLIC_LUMEN_KEY={{key}}"},"code":{"file":"app/layout.tsx","code":"import { Lumen } from \"@lumen/next\";\n\nexport default function RootLayout({ children }) {\n return (\n <html lang=\"en\">\n <body>{children}<Lumen /></body>\n </html>\n );\n}"}},{"id":"react","label":"React","install":{"packages":"@lumen/react"},"key":{"file":".env","code":"VITE_LUMEN_KEY={{key}}"},"code":{"file":"src/main.tsx","code":"import { createRoot } from \"react-dom/client\";\nimport { LumenProvider } from \"@lumen/react\";\nimport App from \"./App\";\n\ncreateRoot(document.getElementById(\"root\")!).render(\n <LumenProvider apiKey={import.meta.env.VITE_LUMEN_KEY}>\n <App />\n </LumenProvider>\n);"}},{"id":"vue","label":"Vue","install":{"packages":"@lumen/vue"},"key":{"file":".env","code":"VITE_LUMEN_KEY={{key}}"},"code":{"file":"src/main.ts","code":"import { createApp } from \"vue\";\nimport { lumen } from \"@lumen/vue\";\nimport App from \"./App.vue\";\n\ncreateApp(App)\n .use(lumen, { apiKey: import.meta.env.VITE_LUMEN_KEY })\n .mount(\"#app\");"}},{"id":"html","label":"HTML","install":{"file":"index.html","code":"<script src=\"https://cdn.lumen.dev/v2/lumen.min.js\" defer></script>"},"key":{"file":"index.html","code":"<meta name=\"lumen-key\" content=\"{{key}}\" />"},"code":{"file":"index.html","code":"<script>\n window.addEventListener(\"load\", () => {\n lumen.page();\n document.querySelector(\"#upgrade\").onclick = () =>\n lumen.track(\"upgrade_clicked\", { plan: \"pro\" });\n });\n</script>"}}] | Framework tabs and their step snippets (install, key, code). Write {{key}} where the API key goes; ids next, react, vue, and html get built-in marks automatically. |
defaultFramework | string— | Initial framework tab ID when uncontrolled. Defaults to the first framework; edits do not reset a mounted instance. |
defaultPackageManager | 'npm' | 'pnpm' | 'yarn' | 'bun'Default: "npm" | Initial package manager used in step 1 when uncontrolled. Edits do not reset a mounted instance. |
apiKey | string— | Pre-populated API key shown in place of {{key}}. Hides the Generate key button for signed-in users who already have a key. |
keyPlaceholder | stringDefault: "YOUR_API_KEY" | Tinted placeholder displayed wherever {{key}} appears until a key exists. Copies verbatim when copied before key generation. |
generateKeyAction | string— | Registered host action requested when the user clicks Generate key, Regenerate, or Try again. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | InstallSnippetThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | InstallSnippetMotionOptionsDefault: {} | Sliding tab highlight, snippet crossfade, and key-wipe timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
InstallSnippetFramework accepts { id, label, install, key, code }, where install is { packages: string } or { file, code }, and key and code are { file, code }.
React integration
| Prop | Purpose |
|---|---|
framework | Controlled framework tab ID. Pair with onFrameworkChange. |
onFrameworkChange(id) | Called when the user selects a framework tab. |
packageManager | Controlled package manager ('npm' | 'pnpm' | 'yarn' | 'bun'). Pair with onPackageManagerChange. |
onPackageManagerChange(id) | Called when the user selects a package manager tab (useful for persisting choice across docs pages). |
generateKey(signal) | Async key creator returning Promise<string>. Reject to show the error state with Try again. |
onKeyGenerated(key) | Called with each newly created key string. |
onCopy(step, value) | Called after a successful copy with 'install' | 'key' | 'code' and the exact clipboard text. |
onAction(action) | Called when generateKeyAction is configured and the user activates Generate key, Regenerate, or Try again. |
description, version | Also accept null or "" in React to hide the subtitle or version label. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves between framework tabs, package manager tabs, copy buttons, and the Generate key button. |
ArrowLeft / ArrowRight | Inside a tab list, moves focus to and selects the previous or next tab (respects RTL). |
Home / End | Inside a tab list, selects the first or last tab. |
Enter / Space | Activates a copy button or triggers key generation. |
Framework and package manager switchers are real tablist controls with roving tabindex; the three-step <ol> serves as the framework tabpanel. Completed steps append visually hidden ", done" text to their <h4> headings alongside the check icon, so completion never relies on color alone. A pre-mounted polite role="status" live region announces framework switches, key generation progress, simulated-key notices, and errors.
Container queries adapt the card below 640px: at 460px and narrower, card padding tightens and package manager tabs display marks only (retaining aria-label names); at 380px and narrower, framework tabs hide their marks to keep labels legible and hide the version tag. Code blocks scroll horizontally inside their container (dir="ltr") while surrounding card chrome mirrors cleanly in RTL (dir="rtl"). forced-colors: active maps borders, tab indicators, step circles, key slots, and focus outlines to system colors.
Motion & theming
Tab highlights slide to the measured tab on a bounce-free 240ms spring. Snippets, filenames, and step descriptions crossfade inside a shared grid cell (100ms out, 160ms in with a 2px rise) while every code block reserves the height of the tallest framework snippet so nothing jumps. Generating a key eases the slot width in ch units while wiping the key in over 340ms and fading the accent tint out. Under prefers-reduced-motion: reduce, slides, rises, and clip-path wipes are replaced with 120ms opacity crossfades. Setting motion="none" makes every transition immediate (0ms).
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
type | --ui-font-mono, --ui-font-display |
series | --ui-series-1, --ui-series-2, --ui-series-3, --ui-series-4 (softened toward --ui-text for lightweight syntax highlighting) |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, InstallSnippet is a leaf. Provide frameworks with {{key}} placeholders and wire generateKeyAction to a registered host action. See Building with agents.
{
"type": "InstallSnippet",
"props": {
"title": "Get started in 30 seconds",
"description": "Three steps to your first event.",
"version": "v2.4.0",
"defaultPackageManager": "pnpm",
"keyPlaceholder": "YOUR_API_KEY",
"generateKeyAction": "generate_sdk_key"
},
"children": []
}