mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-30 11:12:58 +00:00
esbuild 0.27.7 was pinned in the database-wasm-vite lockfile even though Vite already accepts the 0.28 line. Move to the current release so the example does not keep an aging toolchain around. Only the lockfile changes: esbuild is a transitive dev dependency, so the bump covers esbuild plus its 26 platform packages and nothing else. Tests: npm install && npm run build in examples/javascript/database-wasm-vite
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" }
]
}
]
}