---
title: "Local development"
description: "Run a development copy of Calends, the common commands, how the code is laid out, and what to check before a pull request."
lang: "en"
version: "1.84.0"
url: "https://docs.calends.date/en/self-host/development/"
markdown_url: "https://docs.calends.date/en/self-host/development.md"
section: "Self-hosting"
llms_index: "https://docs.calends.date/llms.txt"
llms_full: "https://docs.calends.date/llms-full.txt"
agents_guide: "https://calends.date/AGENTS.md"
---

# Local development

> Run a development copy of Calends, the common commands, how the code is laid out, and what to check before a pull request.

- Canonical page: https://docs.calends.date/en/self-host/development/
- Markdown source: https://docs.calends.date/en/self-host/development.md
- Calends version: v1.84.0

Use this guide to start a development environment and run checks before changing Calends source code.

1. Install Node.js 24, clone the repository and run the setup commands below.
2. Open the local app; follow the instructions for `.dev.vars` if you need to bypass sign-in.
3. Run checks relevant to your changes, then review the full checklist before submitting.

## Start

You'll need Node.js 24.

```bash
git clone https://github.com/imetn/calends && cd calends
npm ci
npm run db:migrate:local
npm run dev
```

To bypass sign-in during development, add `DEV_BYPASS_AUTH=1` to `.dev.vars`, preserving existing contents.

`npm run dev` starts two processes: Vite (front end with hot reload, bound to `0.0.0.0:5173` with LAN and Tailscale `*.ts.net` access) and wrangler (the Worker and a local D1, `:8787`), with a watchdog that automatically restarts the Worker if its port stops responding without restarting Vite. Open `http://127.0.0.1:5173` locally.

The local database is kept in `.wrangler/state` at the repository root.

> **DANGER**: `DEV_BYPASS_AUTH=1` skips sign-in entirely. Only put it in your local `.dev.vars`; never configure it in production.

## Common commands

| Command | What it does |
| --- | --- |
| `npm test` | Unit tests (billing, phases, metrics, shared plans, categories and more) |
| `npm run typecheck` | TypeScript type check |
| `npm run lint` | oxlint |
| `npm run format` / `npm run format:check` | Prettier format / check |
| `npm run i18n:check` | Checks every language has every string |
| `npm run build` | Production build |
| `npm run email:preview` | Renders every reminder email with sample data into `.preview/email/` as HTML; sends nothing |

## Code layout

```text
app/src/    app and public page
shared/     billing, phases, metrics, FX, masking, i18n — shared by browser and Worker
worker/     API, auth (password + passkeys), MCP, reminders and channels, backup, ICS
worker/migrations/ D1 / SQLite schema
docker/     self-hosting image entrypoint
```

Stack: React 19, the React Compiler and Vite for the app, with HeroUI / React Aria for dialogs, menus and controls; shadcn/ui for the public page; Cloudflare Workers + D1 on the server.

## Before a pull request

```bash
npm run typecheck && npm run lint && npm run format:check && npm run i18n:check && npm test && npm run build
```

A few ground rules (see `CONTRIBUTING.md` in the repository):

- **Domain logic lives in `shared/`** and must run in both the browser and the Worker — no DOM or Node APIs. Add unit tests in `shared/*.test.ts` for billing, phase or metric changes.
- **Every user-visible string goes through `t()`**, and never at module top level. Add new strings to `en` and `zh-CN` at least.
- **Keep stored data compatible.** Old records must keep working; schema changes go in a new file under `worker/migrations/`; new data must round-trip through [backups](https://docs.calends.date/en/data/backup.md).
- **Privacy**: anything that could identify a person or account stays off the public page; `shared/mask.ts` allow-lists what's shared.
- Keep the UI consistent with existing components and check phone width (390px), desktop, light and dark.

Use an isolated `.wrangler/state` and fictional data for import, restore and migration checks. The public demo is a dedicated deployment, not an `npm run demo` seed command. Read the repository’s `AGENTS.md`, `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing a subsystem.

---

## Related Pages & Global AI Discovery

To explore broader context beyond this page, fetch any of the Markdown or plain-text resources below directly:

### Same Section (Self-hosting)
- [Cloudflare Workers + D1](https://docs.calends.date/en/self-host/cloudflare.md)
- [Docker](https://docs.calends.date/en/self-host/docker.md)
- [Configuration](https://docs.calends.date/en/self-host/config.md)
- [Custom domain and HTTPS](https://docs.calends.date/en/self-host/custom-domain.md)
- [Upgrading](https://docs.calends.date/en/self-host/upgrade.md)
- [Local development](https://docs.calends.date/en/self-host/development.md) *(current)*
- [Translating](https://docs.calends.date/en/self-host/translate.md)

### Reading Order
- Previous: [Upgrading](https://docs.calends.date/en/self-host/upgrade.md)
- Next: [Translating](https://docs.calends.date/en/self-host/translate.md)

### Global Calends Resources
- Read-only Docs MCP Server (zero auth Streamable HTTP): https://docs.calends.date/mcp
- Complete Docs Index (all 37 topics with `.md` links): https://docs.calends.date/llms.txt
- Complete English Docs Bundle (single file): https://docs.calends.date/llms-full.txt
- Complete Simplified Chinese Docs Bundle: https://docs.calends.date/llms-zh.txt
- Docs AI Agent Guide: https://docs.calends.date/AGENTS.md
- Product Website Overview (Markdown): https://calends.date/en/index.md
- Product LLMs Index & Full Reference: https://calends.date/llms.txt | https://calends.date/llms-full.txt
- Deployment & MCP Agent Guide (AGENTS.md): https://calends.date/AGENTS.md
- FAQ & Calends vs Wallos Comparison (Markdown): https://calends.date/en/faq.md | https://calends.date/en/compare.md
- Complete Changelog (Markdown): https://calends.date/en/releases.md
