npm + Vite Example
@responsivevoice/core installed from npm and bundled for the browser by Vite. Same feature set as the Basic Example, but the library arrives via ESM import instead of a CDN <script> tag — the path modern web apps actually use.
Quick start
Section titled “Quick start”npm installnpm run vite:dev# open http://localhost:5173/Minimal integration
Section titled “Minimal integration”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
Section titled “Production bundle”npm run vite:buildnpm run vite:previewNext Steps
Section titled “Next Steps”- Basic Example — the CDN counterpart using the same API surface
- Extended Usage Example — full feature walkthrough