.wasm files with the correct MIME type and keep them as external assets instead of inlining them into JavaScript.
- Vite
- Next.js
Use the official AvatarKit Vite plugin:
vite.config.ts
What the plugin configures
What the plugin configures
The Vite plugin handles the WASM requirements for both development and production:
- Serves
.wasmfiles asapplication/wasmin the Vite dev server - Copies AvatarKit WASM files into
dist/assets/during builds - Generates a
_headersfile for Cloudflare Pages deployments - Configures Vite options such as
optimizeDeps,assetsInclude, andassetsInlineLimit
Manual Vite configuration
Manual Vite configuration
Use this only if you cannot use
avatarkitVitePlugin():vite.config.ts
Verify Setup
After configuring your toolchain, run your app and confirm the AvatarKit.wasm request succeeds:
- The request should return
200 - The response header should include
Content-Type: application/wasm - The file should be loaded as a separate
.wasmasset, not inlined into JavaScript