proxy-dynamic-wasm-compilation.mdx


title: Dynamic WASM compilation is not available in Proxies

Why This Error Occurred

Compiling WASM binaries dynamically is not allowed in Proxies. Specifically, the following APIs are not supported:

Possible Ways to Fix It

Bundle your WASM binaries using import:

import { NextResponse } from 'next/server'
import squareWasm from './square.wasm?module'

export default async function proxy() {
  const m = await WebAssembly.instantiate(squareWasm)
  const answer = m.exports.square(9)
  const response = NextResponse.next()

  response.headers.set('x-square', answer.toString())
  return response
}

Rendered from the public repository vercel/next.js on GitHub; content belongs to its authors. Cached for up to an hour.

errors/proxy-dynamic-wasm-compilation.mdx · vercel/next.js | Docs MD