Skip to main content
Get your local development environment up and running to start contributing to Twenty or customizing it for your needs.

Prerequisites

Before you begin, ensure you have the following installed:
  • Node.js 24+ (required)
  • Yarn 4 (4.0.2 or higher)
  • PostgreSQL (version 16 recommended)
  • Redis (latest stable version)
  • Git
Twenty uses Yarn 4 as its package manager. The project is set up with packageManager: "[email protected]" to ensure version consistency.

Clone the Repository

First, clone the Twenty repository:
git clone https://github.com/twentyhq/twenty.git
cd twenty

Install Dependencies

Install all project dependencies using Yarn:
yarn install
This will install dependencies for all packages in the monorepo.

Environment Configuration

Server Configuration

Create your environment file from the example:
cp packages/twenty-server/.env.example packages/twenty-server/.env
Edit packages/twenty-server/.env with your local configuration:
NODE_ENV=development
PG_DATABASE_URL=postgres://postgres:postgres@localhost:5432/default
REDIS_URL=redis://localhost:6379
APP_SECRET=replace_me_with_a_random_string
SIGN_IN_PREFILLED=true
FRONTEND_URL=http://localhost:3001
Generate a secure APP_SECRET using: openssl rand -base64 32

Frontend Configuration

The frontend typically doesn’t require additional configuration for local development, but you can create an .env file if needed:
cp packages/twenty-front/.env.example packages/twenty-front/.env

Database Setup

Start PostgreSQL and Redis

Make sure PostgreSQL and Redis are running:
brew services start postgresql@16
brew services start redis

Initialize the Database

Reset and initialize the database:
npx nx database:reset twenty-server
This command will:
  • Drop and recreate the database
  • Run all migrations
  • Seed with initial data

Start Development Server

Start all services (frontend, backend, and worker) at once:
yarn start
This command runs:
  • Frontend on http://localhost:3001
  • Backend on http://localhost:3000
  • Worker for background jobs
The yarn start command uses concurrently to run multiple services. It waits for the backend to be ready before starting the worker.

Start Individual Services

You can also start services individually:
npx nx start twenty-front

Verify Installation

  1. Open your browser and navigate to http://localhost:3001
  2. Click “Continue with Email”
  3. Use the prefilled credentials to sign in
  4. You should see the Twenty dashboard

Development Commands

Testing

# Run a single test file (recommended for speed)
npx jest path/to/test.test.ts --config=packages/PROJECT/jest.config.mjs

# Run all tests for a package
npx nx test twenty-front
npx nx test twenty-server

# Run integration tests with database reset
npx nx run twenty-server:test:integration:with-db-reset

Code Quality

# Lint changes (fastest - always prefer this)
npx nx lint:diff-with-main twenty-front
npx nx lint:diff-with-main twenty-server

# Auto-fix linting issues
npx nx lint:diff-with-main twenty-front --configuration=fix

# Type checking
npx nx typecheck twenty-front
npx nx typecheck twenty-server

# Format code
npx nx fmt twenty-front
npx nx fmt twenty-server

Database Operations

# Reset database
npx nx database:reset twenty-server

# Run migrations
npx nx run twenty-server:database:migrate:prod

# Generate a new migration
npx nx run twenty-server:typeorm migration:generate \
  src/database/typeorm/core/migrations/common/[name] \
  -d src/database/typeorm/core/core.datasource.ts

# Sync metadata
npx nx run twenty-server:command workspace:sync-metadata

GraphQL

# Generate GraphQL types after schema changes
npx nx run twenty-front:graphql:generate
npx nx run twenty-front:graphql:generate --configuration=metadata

Common Issues

If port 3000 or 3001 is already in use, you can:
  • Stop the conflicting process
  • Change the port in your .env file:
    PORT=3002
    FRONTEND_URL=http://localhost:3003
    
Verify PostgreSQL is running and the connection string is correct:
psql postgres://postgres:postgres@localhost:5432/default
If the database doesn’t exist, create it:
createdb -U postgres default
Ensure Redis is running:
redis-cli ping
# Should return: PONG
Clean and reinstall dependencies:
yarn clean
yarn install
npx nx build twenty-shared
yarn start

Next Steps

Architecture Overview

Learn about Twenty’s technical architecture

Contributing Guide

Start contributing to Twenty

Code Style Guide

Follow Twenty’s code conventions

Testing

Write and run tests

Build docs developers (and LLMs) love