← Back to Examples

npm + Vite Recipe

ResponsiveVoice imported from npm as an ESM module, bundled by Vite. This is a developer recipe — clone the examples repo and run locally to try it.

How to run this example
  1. Get a free API key at responsivevoice.org/register
  2. Clone the repo: git clone https://github.com/ResponsiveVoice/examples.git
  3. Install deps: npm install
  4. Start the Vite dev server: npm run vite:dev
  5. Edit browser/vite/src/main.ts — uncomment the apiKey field in rv.init({ ... }) and paste your key
  6. Open http://localhost:5173/

For a production bundle: npm run vite:build && npm run vite:preview.

Same UI as the basic example, but it imports @responsivevoice/core from npm via import { getResponsiveVoice } from '@responsivevoice/core' in src/main.ts — no CDN script tag, no IIFE global. Vite bundles the TypeScript entry for the browser.