---
url: https://void.cloud/integrations/frameworks/analog.md
description: >-
  Add Void to an Analog app for resource detection, typed database queries,
  migrations, and deployment.
---

# Analog

Use Void with [Analog](https://analogjs.org/) for resource detection, typed database queries, and migrations.

## Setup

### 1. Create a new project

```bash
npx create-analog@latest my-app
cd my-app
```

### 2. Install dependencies

```bash
npm install -D void nitro-cloudflare-dev
```

Use `nitro-cloudflare-dev` for local Cloudflare bindings.

### 3. Configure `vite.config.ts`

```ts
import analog from '@analogjs/platform';
import { defineConfig } from 'vite';
import { voidPlugin } from 'void';

export default defineConfig({
  resolve: {
    mainFields: ['module'],
  },
  plugins: [
    analog({
      ssr: true,
      nitro: {
        preset: 'cloudflare-module',
        cloudflareDev: { configPath: './.void-wrangler.jsonc' },
        modules: ['nitro-cloudflare-dev', 'void/nitro'],
      },
    }),
    voidPlugin(),
  ],
});
```

The `void/nitro` module gives Analog API routes and page server loads your app's `void/db` and `@schema`.

### 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'],
  },
});
```

`nodejs_compat` is required for Nitro's Cloudflare runtime. `nodejs_als` is required for `void/*` runtime helpers (e.g. `void/db`, `void/kv`).

### 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](../../guide/deployment.md).

## Using Void Features

Use Void resources in page server loaders, actions, and API routes. For authentication, use your framework’s Better Auth integration.

### Database

To show the users from your database on an Analog page, query your `users` table in its server loader.

```ts
// src/app/pages/users.server.ts
import type { PageServerLoad } from '@analogjs/router';
import { users } from '@schema';
import { db } from 'void/db';

export const load = async ({ event }: PageServerLoad) => {
  return { users: await db.select().from(users) };
};
```

### Other resources

See [supported resources and background jobs](./overview.md#feature-support) 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](../../guide/env-vars.md) for local values, production secrets, and public `VITE_*` values.

## Accessing Bindings Directly

You can also access raw Cloudflare bindings via the H3 event context or the `cloudflare:workers` module:

```ts
// src/server/routes/api/users.ts
import { env } from 'cloudflare:workers';
import { eventHandler } from 'h3';

export default eventHandler(async () => {
  const { results } = await env.DB.prepare('SELECT * FROM users').all();
  return results;
});
```
