|
| 1 | +--- |
| 2 | +title: 'npx create-db' |
| 3 | +metaTitle: 'Getting started with npx create-db' |
| 4 | +metaDescription: 'Learn how to provision temporary Prisma Postgres databases with npx create-db.' |
| 5 | +sidebar_label: 'npx create-db' |
| 6 | +tocDepth: 3 |
| 7 | +toc: true |
| 8 | +--- |
| 9 | + |
| 10 | +[`create-db`](https://create-db.prisma.io/) is an open-source CLI tool that provisions temporary [Prisma Postgres](/postgres) databases with a single command. |
| 11 | + |
| 12 | +- **Fast setup:** No sign-up required to create a temporary production-ready Prisma Postgres database. |
| 13 | +- **Lifetime:** Each database is available for _24 hours_ by default. |
| 14 | +- **Keep for free:** You can _claim_ a database (via the URL provided in the CLI output) to make it permanent. |
| 15 | + |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +To use `npx create-db`, you need: |
| 20 | + |
| 21 | +- **Node.js** version `16` or higher (we recommend the latest LTS version). |
| 22 | +- **npm** (comes with Node.js) to run `npx` commands. |
| 23 | + |
| 24 | +**A Prisma Data Platform account is not required** to create a temporary database. However, if you want to keep a database permanently, you can claim it ([details below](#claiming-your-database)). |
| 25 | + |
| 26 | + |
| 27 | +## Getting started |
| 28 | + |
| 29 | +You can create a database using one of the following options: |
| 30 | + |
| 31 | +### Option 1: Quick start with default settings |
| 32 | + |
| 33 | +Run the following command in your terminal: |
| 34 | + |
| 35 | +```terminal |
| 36 | +npx create-db@latest |
| 37 | +``` |
| 38 | + |
| 39 | +<br/> |
| 40 | + |
| 41 | +- The `@latest` tag automatically downloads and runs the latest version of the tool, hence, no global installation required. |
| 42 | +- After a few seconds, you'll receive **connection strings** for both Prisma ORM projects and standard PostgreSQL. |
| 43 | +- The default region is `us-east-1`. You can specify the region where you want to provision the database in using the `--region` flag. See [the section below](#available-cli-options) to view all the CLI options. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +### Option 2: Choose a region interactively |
| 48 | + |
| 49 | +If you want to select a region manually: |
| 50 | + |
| 51 | +```terminal |
| 52 | +npx create-db@latest --interactive |
| 53 | +``` |
| 54 | + |
| 55 | +<br/> |
| 56 | + |
| 57 | +- This opens a region selection menu (for example, `us-east-1`, `eu-west-3`). |
| 58 | +- Alternatively, you can use the shorthand `-i`: |
| 59 | + |
| 60 | +```terminal |
| 61 | +npx create-db@latest -i |
| 62 | +``` |
| 63 | + |
| 64 | +To view all options and regions: |
| 65 | + |
| 66 | +```terminal |
| 67 | +npx create-db@latest --help |
| 68 | +``` |
| 69 | + |
| 70 | +## CLI output walkthrough |
| 71 | + |
| 72 | +Here is an example output: |
| 73 | + |
| 74 | +``` |
| 75 | +┌ 🚀 Creating a Prisma Postgres database |
| 76 | +│ |
| 77 | +│ Provisioning a temporary database in us-east-1... |
| 78 | +│ |
| 79 | +│ It will be automatically deleted in 24 hours, but you can claim it. |
| 80 | +│ |
| 81 | +◇ Database created successfully! |
| 82 | +│ |
| 83 | +● Connect to your database → |
| 84 | +│ |
| 85 | +│ Use this connection string optimized for Prisma ORM: |
| 86 | +│ prisma+postgres://accelerate.prisma-data.net/?api_key=... |
| 87 | +│ |
| 88 | +│ Use this connection string for everything else: |
| 89 | +│ postgresql://<username>:<password>@db.prisma.io:5432/postgres |
| 90 | +│ |
| 91 | +◆ Claim your database → |
| 92 | +│ |
| 93 | +│ Want to keep your database? Claim for free: |
| 94 | +│ https://create-db.prisma.io?projectID=proj_... |
| 95 | +└ |
| 96 | +``` |
| 97 | + |
| 98 | + |
| 99 | +Once you have the output, take the **Prisma ORM-optimized connection string** (`prisma+postgres://...`) and add it to your `.env` file as `DATABASE_URL`: |
| 100 | + |
| 101 | +```env |
| 102 | +DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=..." |
| 103 | +``` |
| 104 | + |
| 105 | +You can now follow the [Prisma Postgres quickstart guide](/getting-started/quickstart-prismaPostgres#3-set-database-connection-url) to connect your Prisma project to this database. |
| 106 | + |
| 107 | +If you're using other tools or libraries, use the **standard PostgreSQL connection string** (`postgresql://...`) with any PostgreSQL-compatible client, such as `psql`, `pgAdmin`, `node-postgres`, or an ORM of your choice. Detailed instructions are available in the guide for [connecting via direct PostgreSQL connection string](/postgres/database/direct-connections). |
| 108 | + |
| 109 | + |
| 110 | +## Claiming your database |
| 111 | + |
| 112 | +By default, databases created with `npx create-db` are **temporary** and will be automatically deleted after **24 hours**. |
| 113 | + |
| 114 | +You can prevent this by **claiming the database** using the claim URL shown in the CLI output: |
| 115 | + |
| 116 | +``` |
| 117 | +◆ Claim your database → |
| 118 | +│ |
| 119 | +│ Want to keep your database? Claim for free: |
| 120 | +│ |
| 121 | +│ https://create-db.prisma.io?projectID=proj_... |
| 122 | +│ |
| 123 | +│ Your database will be deleted on 7/24/2025, 2:25:41 AM if not claimed. |
| 124 | +``` |
| 125 | + |
| 126 | +To claim your database and make it permanent: |
| 127 | + |
| 128 | +1. Copy the **claim URL** from the CLI output. |
| 129 | +2. Open it in your browser and click **Claim database**. |
| 130 | +3. Sign in to your [Prisma Data Platform account](https://console.prisma.io/) (or create one if you don’t have it yet). |
| 131 | +4. Choose a **Workspace** that has capacity for creating new projects. |
| 132 | +5. Click **Authorize Prisma Create DB** to confirm. |
| 133 | +6. You’ll be redirected to a success page. Then, click **Go use your database** to view and manage the claimed database in your workspace. |
| 134 | + |
| 135 | +When you claim a database: |
| 136 | + |
| 137 | +- It's moved into your Prisma Data Platform account workspace. |
| 138 | +- It's no longer auto-deleted after 24 hours. |
| 139 | +- You can continue using it as a permanent database instance. |
| 140 | + |
| 141 | +## Available CLI options |
| 142 | + |
| 143 | +Here are the CLI flags for the `npx create-db` command: |
| 144 | + |
| 145 | +| Flag | Shorthand | Description | |
| 146 | +|---------------|-----------|----------------------------------------------------------------------------------------------| |
| 147 | +| `--region` | `-r` | Specify a region. <br /> **Available regions:** `ap-southeast-1`, `ap-northeast-1`, `eu-central-1`, `eu-west-3`, `us-east-1`, `us-west-1` | |
| 148 | +| `--interactive` | `-i` | Run in interactive mode (select region from a list). | |
| 149 | +| `--help` | `-h` | Show this help message. | |
| 150 | + |
| 151 | + |
| 152 | +To view all CLI options use the `--help` or `-h` flag: |
| 153 | + |
| 154 | +<CodeWithResult expanded={false}> |
| 155 | + |
| 156 | +<cmd> |
| 157 | + |
| 158 | +```terminal |
| 159 | +npx create-db@latest --help |
| 160 | +``` |
| 161 | + |
| 162 | +</cmd> |
| 163 | + |
| 164 | +<cmdResult> |
| 165 | + |
| 166 | +``` |
| 167 | +npx create-db@latest [options] |
| 168 | +
|
| 169 | +Options: |
| 170 | + --region <region>, -r <region> Specify a region |
| 171 | + Available regions: |
| 172 | + ap-southeast-1, ap-northeast-1, |
| 173 | + eu-central-1, eu-west-3, |
| 174 | + us-east-1, us-west-1 |
| 175 | +
|
| 176 | + --interactive, -i Run in interactive mode |
| 177 | +
|
| 178 | + --help, -h Show this help message |
| 179 | +``` |
| 180 | +</cmdResult> |
| 181 | + |
| 182 | +</CodeWithResult> |
0 commit comments