Requirements
Zero requires Node.js 22 or higher and a PostgreSQL database (version 15+).
- Node.js 22+ installed (download)
- PostgreSQL 15+ running locally or remotely
- Docker (optional, for local PostgreSQL development)
Install Zero
Install the package
Install Zero using npm, pnpm, or yarn:The
@rocicorp/zero package includes everything you need:- Client-side library for queries and mutations
- Server-side sync engine (zero-cache)
- Schema builder and type definitions
- CLI tools for running the sync server
Install React bindings (optional)
If you’re using React, the React hooks are included in the main package:For other frameworks:
Set up PostgreSQL
Zero requires a PostgreSQL database as the source of truth.Start PostgreSQL:
Option 1: Docker (Recommended for Development)
Create adocker-compose.yml file:docker-compose.yml
Option 2: Local PostgreSQL
If you have PostgreSQL installed locally, ensure it’s running and create a database:Option 3: Cloud PostgreSQL
You can use any PostgreSQL provider:Verify Installation
Create a simple test file to verify Zero is installed correctly:test-zero.ts
Development Setup
For a complete development workflow, you’ll typically run three processes:1. PostgreSQL Database
2. Zero Cache Server
The zero-cache server syncs data between PostgreSQL and clients:3. Your Application
Run your web application:Package Scripts
Add these convenience scripts to yourpackage.json:
package.json
Building from Source
Most users should use the npm package. Only build from source if you’re contributing to Zero or need unreleased features.
Troubleshooting
Port Conflicts
If port 4848 is already in use:PostgreSQL Connection Issues
Verify your connection string:- Wrong password or username
- PostgreSQL not running
- Firewall blocking port 5432
- Wrong database name
SQLite Replica Issues
If you see stale data or corruption:Next Steps
Quick Start
Build your first Zero application
Schema Definition
Learn how to define your data schema