> ## Documentation Index
> Fetch the complete documentation index at: https://docs.responsivevoice.org/llms.txt
> Use this file to discover all available pages before exploring further.

# npm + Vite Example

`@responsivevoice/core` installed from npm and bundled for the browser by [Vite](https://vitejs.dev/). Same feature set as the [Basic Example](/examples/basic), but the library arrives via ESM `import` instead of a CDN `<script>` tag — the path modern web apps actually use.

> [!TIP]
> [Source code](https://github.com/responsivevoice/examples/tree/main/browser/vite)

## Quick start

```bash
npm install
npm run vite:dev
# open http://localhost:5173/
```

## Minimal integration

```ts
import { getResponsiveVoice } from '@responsivevoice/core';

const rv = await getResponsiveVoice();

rv.addEventListener('OnReady', () => {
  rv.speak('Hello from Vite!');
});

rv.init({
  // Get a free API key at https://responsivevoice.org/register
  // apiKey: 'YOUR_RESPONSIVEVOICE_API_KEY',
});
```

`getResponsiveVoice()` returns the singleton instance — the same object that the CDN IIFE exposes as `window.responsiveVoice`. Attach listeners first, then call `init()` so `OnReady` reliably fires into your handlers.

## Production bundle

```bash
npm run vite:build
npm run vite:preview
```

## Next Steps

- [Basic Example](/examples/basic) — the CDN counterpart using the same API surface
- [Extended Usage Example](/examples/extended) — full feature walkthrough
