Files
turso/examples/javascript/database-wasm-vite
dependabot[bot] 1a11529a3c build(deps-dev): bump source-map-js
Bumps [source-map-js](https://github.com/7rulnik/source-map-js) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/7rulnik/source-map-js/releases)
- [Changelog](https://github.com/7rulnik/source-map-js/blob/main/CHANGELOG.md)
- [Commits](https://github.com/7rulnik/source-map-js/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: source-map-js
  dependency-version: 1.2.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-14 08:01:59 +00:00
..

database-wasm-vite

This is a minimal example showing how to use @tursodatabase/database-wasm in the browser with Vite.


Usage

npm install
npm run dev
# or build assets and serve them with simple node.js server
npm run build
npm run serve

Important: COOP / COEP Headers

Because @tursodatabase/database-wasm relies on SharedArrayBuffer, you need Cross-Origin headers in development and production:

Vite dev server config (vite.config.js)

import { defineConfig } from 'vite'

export default defineConfig({
  server: {
    headers: {
      'Cross-Origin-Opener-Policy': 'same-origin',
      'Cross-Origin-Embedder-Policy': 'require-corp',
    }
  }
})

Static production server (server.mjs)

When serving the dist/ build, also make sure your server sets these headers:

res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");

Vercel deployment

If you deploy to Vercel, add a vercel.json file to ensure COOP / COEP headers are set:

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        { "key": "Cross-Origin-Opener-Policy", "value": "same-origin" },
        { "key": "Cross-Origin-Embedder-Policy", "value": "require-corp" }
      ]
    }
  ]
}