TanStack Start
Add voidPlugin() alongside the TanStack Start Vite plugin to use Void's database, storage, and deployment features. Void includes the Cloudflare adapter.
Setup
1. Create a new project
npm create @tanstack/start@latest my-app
cd my-app2. Install dependencies
npm install -D void3. Configure vite.config.ts
import { tanstackStart } from '@tanstack/react-start/plugin';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { voidPlugin } from 'void';
export default defineConfig({
plugins: [
voidPlugin(), // must come before the framework plugin
tanstackStart(),
react(),
],
});4. Deploy
void connect --platform cloudflare
void deployvoid 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 functions. For authentication, use your framework’s Better Auth integration.
Database
To fetch your users from a TanStack Start component, define a server function that queries the users table.
import { users } from '@schema';
import { createServerFn } from '@tanstack/react-start';
import { db } from 'void/db';
const getUsers = createServerFn().handler(async () => {
return db.select().from(users);
});Other resources
See supported resources and background jobs for KV, storage, AI, cron jobs, and queues.
To run a queue consumer locally, start the dev server and use the manual queue trigger. Use the dev server’s port and the token in .void/dev-trigger-token. Calling send() in dev or preview accepts the message without running the consumer. Preview reads queues/ and env.ts from your project, so keep both as they were when you built the app.
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.
Custom Worker Entry
Set cloudflare.main in void.config.ts when your Worker needs its own entry module, for example to export a Durable Object class:
import { defineConfig } from 'void/config';
export default defineConfig({
cloudflare: { main: './server.ts' },
});The path is relative to your app root. Default-export the TanStack request handler and add your named exports in that module:
import handler from '@tanstack/react-start/server-entry';
export { Counter } from './counter';
export default handler;Void uses TanStack's default server entry unless you set cloudflare.main. You can also use a package entry such as @tanstack/react-start/server-entry.
Bind an exported Durable Object or Workflow class under cloudflare as well, for example in cloudflare.durable_objects. These settings apply when you deploy with void deploy --platform cloudflare. On a Void platform, use Durable State instead.
Accessing Bindings Directly
You can also access Cloudflare bindings via the cloudflare:workers module:
import { env } from 'cloudflare:workers';
const { results } = await env.DB.prepare('SELECT * FROM users').all();