Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.spatius.ai/llms.txt

Use this file to discover all available pages before exploring further.

AvatarKit uses WebAssembly for avatar rendering. Your build tool must serve .wasm files with the correct MIME type and keep them as external assets instead of inlining them into JavaScript.
Required: Complete this setup before initializing the Web SDK. Missing WASM configuration commonly appears as a .wasm 404, an incorrect MIME type error, or a failed SDK initialization.
Use the official AvatarKit Vite plugin:
vite.config.ts
import { defineConfig } from 'vite'
import { avatarkitVitePlugin } from '@spatialwalk/avatarkit/vite'

export default defineConfig({
  plugins: [
    avatarkitVitePlugin(),
  ],
})
The Vite plugin handles the WASM requirements for both development and production:
  • Serves .wasm files as application/wasm in the Vite dev server
  • Copies AvatarKit WASM files into dist/assets/ during builds
  • Generates a _headers file for Cloudflare Pages deployments
  • Configures Vite options such as optimizeDeps, assetsInclude, and assetsInlineLimit
Use this only if you cannot use avatarkitVitePlugin():
vite.config.ts
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    exclude: ['@spatialwalk/avatarkit'],
  },
  assetsInclude: ['**/*.wasm'],
  build: {
    assetsInlineLimit: 0,
    rollupOptions: {
      output: {
        assetFileNames: (assetInfo) => {
          if (assetInfo.name?.endsWith('.wasm')) {
            return 'assets/[name][extname]'
          }
          return 'assets/[name]-[hash][extname]'
        },
      },
    },
  },
  configureServer(server) {
    server.middlewares.use((req, res, next) => {
      if (req.url?.endsWith('.wasm')) {
        res.setHeader('Content-Type', 'application/wasm')
      }
      next()
    })
  },
})

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 .wasm asset, not inlined into JavaScript
If the WASM request fails, use the Vite plugin or Next.js wrapper above before debugging SDK initialization code.