Skip to content
brought to you byVoidZero

Nuxt ​

Use Void with Nuxt for resource detection, typed database queries, and migrations.

Setup ​

1. Create a new project ​

bash
npm create nuxt@latest my-app
cd my-app

2. Install dependencies ​

bash
npm install -D void

3. Configure nuxt.config.ts ​

ts
import { resolve } from 'node:path';
import { voidPlugin } from 'void';

export default defineNuxtConfig({
  alias: {
    '@schema': resolve(import.meta.dirname, 'db/schema.ts'),
  },
  nitro: {
    preset: 'cloudflare-module',
    modules: ['void/nitro'],
    cloudflare: { dev: { configPath: './.void-wrangler.jsonc' } },
    // Required for Nuxt 4.6.0 on Windows.
    externals: {
      inline: [/[\\/]node_modules[\\/]nuxt[\\/]dist[\\/]/],
    },
  },
  vite: { plugins: [voidPlugin()] },
});

Use void/nitro to access void/db and @schema from server routes. Keep the top-level @schema alias for nuxi typecheck. Nuxt requires compatibilityDate of 2025-07-15 or later for local Cloudflare bindings.

For Nitro 2 or Nitro 3 prereleases, use the Cloudflare development configuration for your Nuxt version.

4. Create void.config.ts ​

ts
import { defineConfig } from 'void/config';

export default defineConfig({
  cloudflare: {
    name: 'my-app',
    compatibility_date: '2026-02-24',
    compatibility_flags: ['nodejs_compat', 'nodejs_als'],
  },
});

5. Deploy ​

bash
void connect --platform cloudflare
void deploy

void connect signs you in to Cloudflare, asks which account to use, and saves it as the deploy target. To deploy to a Void platform run by your team instead, see Deployment.

Using Void Features ​

Use Void resources in server routes and middleware. For authentication, use your framework’s Better Auth integration.

Database ​

To serve a list of users at /api/users, query the users table in a Nuxt server route.

ts
// server/api/users.get.ts
import { users } from '@schema';
import { db } from 'void/db';

export default defineEventHandler(async () => {
  return db.select().from(users);
});

Other resources ​

See supported resources and background jobs for KV, storage, AI, cron jobs, and queues.

Environment Variables ​

Declare variables in env.ts and read them with import { env } from "void/env". See Environment Variables for local values, production secrets, and public VITE_* values.

Use useRuntimeConfig() for other Nuxt runtime settings.

Accessing Bindings Directly ​

You can also access raw Cloudflare bindings via Nitro's event context:

ts
// server/api/users.get.ts
export default defineEventHandler(async (event) => {
  const { DB } = event.context.cloudflare.env;
  const { results } = await DB.prepare('SELECT * FROM users').all();
  return results;
});