Guides
Local development

Local Development

Although you can connect directly to a managed or self hosted instance of a remote Triplit Database, you can also run a local instance of Triplit Database for development purposes. This not only helps separate your development and production environments, but Triplit's local development toolkit provides a lot of help for deploying updates to the Database. For this reason, we recommend running a local instance of Triplit Database when building most projects.

Install the CLI

If you havent already, install the Triplit CLI and initialize a project. You can find instructions for doing so here.

Start Triplit services

To start Triplit services, run the following command in your project directory:

triplit dev

By default this will start the following services:

  • Triplit Console, running at port 6542
  • Triplit Database server, running at port 6543

And prints a usable Serivce API key and Anon API key for connecting to the database.

Additional environment variables

If your project has a .env file, you may set the following environment variables to configure the Triplit Database server:

  • TRIPLIT_SERVICE_TOKEN - The Service API key to use for connecting to the database for CLI commands. If not set, you may use a flag in the CLI (which takes precedent) or the CLI will prompt you for a key.
  • TRIPLIT_DB_URL - The URL to use for connecting to the database. If not set, you may use a flag in the CLI (which takes precedent) or use the default URL for the local database.
  • TRIPLIT_PROJECT_ID - Sets the project identifier used on the local api tokens.
  • TRIPLIT_JWT_SECRET - Overrides the JWT secret used when generating local api tokens.

Database Migrations

Database migrations are also managed locally with the CLI. See Database Migrations for more information on how to manage database migrations.