Local development
Run Huddle on your own computer with a local database, then run the unit and end-to-end tests.
In plain words: this page is for developers who want to change Huddle’s code. It shows how to run a private copy of Huddle on your own computer, with its own empty workspace, and how to run the automatic checks. You don’t need any of this to use or run Huddle for your team.
Everything runs locally: the app, the database, the live updates and the background jobs.
What you need
- Node.js 22 or later
- Git
You don’t need a Cloudflare account to develop locally.
Get the code
git clone https://github.com/Pieter1821/Huddle-Team-Chat.git huddle
cd huddle
npm install
Add your local settings
Copy the example settings file:
cp .dev.vars.example .dev.vars
Then fill in .dev.vars:
ADMIN_EMAIL=you@example.com
BETTER_AUTH_SECRET=paste-at-least-32-random-characters-here
Make a secret with npx @better-auth/cli secret or openssl rand -hex 32. Leave the rest empty. .dev.vars is ignored by Git, so it never ends up in a commit.
Run it
npm run dev
This applies the database migrations to a local database, then starts the app with the Worker running inside Vite’s dev server. Open the address it prints, usually http://localhost:5173.
Without Gmail settings, emails aren’t sent locally: they’re printed in the terminal running npm run dev, sign-in codes included. So on your computer you can sign in as the ADMIN_EMAIL with an emailed code, read it from the terminal, and set up the workspace. Admin › Email says the same.
Local data lives in the .wrangler folder. Delete it to start again with an empty workspace.
Project layout
| Path | What’s there |
|---|---|
src/worker |
The Worker: index.ts (routes), config.ts (settings), modules/ (one folder per feature), realtime/ (Durable Objects), jobs/ (queue and cron), db/ (schema and migration runner) |
src/web |
The React app: features/ (screens), components/, lib/ |
src/shared |
Code used by both, such as mention parsing and colour checks |
migrations |
SQL migrations, generated by drizzle-kit |
public |
Static files: icons, service worker, privacy policy and terms |
test |
Unit and integration tests, run inside the Workers runtime |
e2e |
End-to-end tests in a real browser |
Tests and checks
| Command | What it does |
|---|---|
npm test |
Unit and integration tests with Vitest, in the real Workers runtime |
npm run test:e2e |
End-to-end tests with Playwright against a fresh local copy of Huddle |
npm run typecheck |
TypeScript for the Worker and the app |
npm run lint |
ESLint |
npm run format |
Prettier, fixing formatting |
npm run check |
Everything CI runs: formatting, lint, types, schema check, tests and a production build |
Before the first end-to-end run, install the test browser:
npx playwright install chromium
The end-to-end tests start their own copy of Huddle on port 8790, with an empty database and their own settings, so they never touch your local data or your .dev.vars. They cover signing in, chatting live between two people, threads, files, search, settings, admin, import and export, installing and notifications, accessibility with axe, and the authenticator app.
Changing the database
Edit src/worker/db/schema.ts, then generate a migration:
npm run db:generate
npm run db:check
Commit the new file in migrations/ along with the schema change. The deployed Worker applies it by itself; locally, npm run dev applies it on start.