# Quickstart

Source: https://docs.scenaro.io/introduction/quickstart/

Get a live voice session running on your site in about 15 minutes. This quickstart covers the
embed path — a single provider, a single hook, no transport concepts to learn.

<Info>
  Building an immersive, highly customized experience (custom audio visualizers, avatars,
  multi-participant UI)? See [Advanced: Transport extensions](/guides/advanced-transport-integration)
  once you've got the basics running here.
</Info>

## Prerequisites

- A published scenario UUID from Cockpit
- Node.js 18+ and a React 18+ app
- Microphone access in the browser

## Step 1 — Install the SDK

<CodeGroup>

```bash npm
npm install @scenaro/sdk
```

```bash pnpm
pnpm add @scenaro/sdk
```

</CodeGroup>

## Step 2 — Wrap your app

```tsx
import { ScenaroProvider } from '@scenaro/sdk/react';

export function AppProviders({ children }: { children: React.ReactNode }) {
  return (
    <ScenaroProvider apiUrl="https://api.scenaro.io">
      {children}
    </ScenaroProvider>
  );
}
```

<Warning>
  If your API base URL already includes `/v1` (e.g. `NEXT_PUBLIC_API_URL=https://api.scenaro.io/v1`), pass `apiPathPrefix=""` to `ScenaroProvider` to avoid double-prefixing paths.
</Warning>

## Step 3 — Start a session

```tsx
import { useScenaroSession } from '@scenaro/sdk/react';

const SCENARIO_UUID = 'your-publication-uuid';

export function VoiceButton() {
  const { status, start, end } = useScenaroSession({ scenario: SCENARIO_UUID });

  return status === 'connected'
    ? <button onClick={end}>End session</button>
    : <button onClick={() => start()}>Talk to the assistant</button>;
}
```

That's it — `useScenaroSession` handles identification, session start, transport connection, and
teardown. No transport object to wire up, nothing to render conditionally around it.

## What happens under the hood

<Steps>
  <Step title="Identify">
    The SDK identifies the visitor against the scenario and persists a JWT identity in `localStorage`.
  </Step>
  <Step title="Start session">
    A session is created for the scenario and the SDK opens a connection to the voice agent.
  </Step>
  <Step title="Handshake">
    The SDK receives the scenario's `config` (features, tools, voice stack) and registers your
    frontend tool handlers automatically.
  </Step>
  <Step title="Live">
    `status` becomes `'connected'`, `agentState` reflects what the agent is doing
    (`'listening' | 'thinking' | 'speaking'`), and `messages` accumulates the conversation.
  </Step>
</Steps>

## Reading state and handling messages

```tsx
const {
  status,        // 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'ended'
  agentState,    // 'idle' | 'listening' | 'thinking' | 'speaking'
  messages,      // ConversationMessage[]
  error,         // ScenaroError | null
  sendText,
  setMicrophoneEnabled,
} = useScenaroSession({
  scenario: SCENARIO_UUID,
  onMessage: (message) => console.log(message),
  onError: (error) => console.error(error.code, error.message),
});
```

## Frontend tools

Tools are plain functions — no request IDs, no manual response wrapping:

```tsx
useScenaroSession({
  scenario: SCENARIO_UUID,
  tools: {
    search_products: async ({ query }) => searchCatalog(query),
    open_page: async ({ url }) => {
      router.push(url);
      return { ok: true };
    },
  },
});
```

See [Authentication](/build/authentication) for caching, token refresh, and `external_id` behavior.

## Environment variables

| Variable | Example | Purpose |
|----------|---------|---------|
| `VITE_SCENARO_API_URL` | `https://api.scenaro.io` | API base URL (Vite apps) |
| `NEXT_PUBLIC_API_URL` | `https://api.scenaro.io/v1` | API base URL (Next.js — adjust `apiPathPrefix`) |

## Next steps

- [Implement an experience](/introduction/implement-an-experience) — full developer journey
- [Tools and features](/build/tools-and-features) — session tools vs FeatureProvider
- [Feature registry](/build/feature-registry) — wire tool calls to UI components
- [Embed voice on a website](/guides/recipes/embed-voice-website) — full production recipe
