Skip to content

Commit c3c4c82

Browse files
ankur-archmhessdevnikolasburk
authored
feat: add docs for npx create-db (#7029)
* feat: add docs for npx create-db * Update content/200-orm/500-reference/200-prisma-cli-reference.mdx Co-authored-by: Nikolas <[email protected]> * Update content/200-orm/500-reference/200-prisma-cli-reference.mdx Co-authored-by: Nikolas <[email protected]> * Update content/200-orm/500-reference/200-prisma-cli-reference.mdx Co-authored-by: Nikolas <[email protected]> * Update content/200-orm/500-reference/200-prisma-cli-reference.mdx Co-authored-by: Nikolas <[email protected]> * Update content/250-postgres/100-introduction/220-npx-create-db.mdx Co-authored-by: Nikolas <[email protected]> * Update content/250-postgres/100-introduction/220-npx-create-db.mdx Co-authored-by: Nikolas <[email protected]> * Update content/250-postgres/100-introduction/220-npx-create-db.mdx Co-authored-by: Nikolas <[email protected]> * Update content/250-postgres/100-introduction/220-npx-create-db.mdx Co-authored-by: Nikolas <[email protected]> * added note to getting started` --------- Co-authored-by: Marc Hess <[email protected]> Co-authored-by: Nikolas <[email protected]>
1 parent 01ffd0b commit c3c4c82

File tree

3 files changed

+215
-2
lines changed

3 files changed

+215
-2
lines changed

content/200-orm/500-reference/200-prisma-cli-reference.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,3 +1588,23 @@ To activate usage of the proxy, provide either of the following environment vari
15881588

15891589
- [`HTTP_PROXY`](/orm/reference/environment-variables-reference#http_proxy) or `http_proxy`: Proxy URL for http traffic, for example `http://localhost:8080`
15901590
- [`HTTPS_PROXY`](/orm/reference/environment-variables-reference#https_proxy) or `https_proxy`: Proxy URL for https traffic, for example `https://localhost:8080`
1591+
1592+
1593+
## `npx create-db`
1594+
1595+
The [`create-db`](https://create-db.prisma.io/) command provisions a temporary [Prisma Postgres](/postgres) database with a single command. This is a standalone utility that can be invoked using `npx`. It's ideal for quickly testing, prototyping, or integrating with Prisma Postgres.
1596+
1597+
You can run the following variants:
1598+
1599+
| Command | Description |
1600+
| --------------------- | --------------------------------------------- |
1601+
| `npx create-db@latest` | Creates a temporary Prisma Postgres database. |
1602+
| `npx create-pg@latest` | Alias for `npx create-db`. |
1603+
| `npx create-postgres@latest` | Alias for `npx create-db`. |
1604+
1605+
Each database created with these commands:
1606+
1607+
* Is available for **24 hours** by default.
1608+
* Can be **claimed for free** to make it permanent using the URL displayed in the CLI output.
1609+
1610+
For full usage details, options (such as `--region` and `--interactive`), and examples, see the [documentation](/postgres/introduction/npx-create-db).

content/250-postgres/100-introduction/200-getting-started.mdx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ toc: true
88

99
## Quickstart
1010

11-
Run the following command in your terminal to create a fresh Prisma Postgres instance:
11+
12+
To **bootstrap a new Prisma ORM project with a Prisma Postgres database**, run the following command in your terminal:
1213

1314
```terminal
1415
npx prisma init --db
1516
```
1617

17-
Once you ran this command, the terminal will output instructions for you to [follow the steps on this page](/getting-started/prisma-postgres/from-the-cli) in order to set up your first project with Prisma Postgres.
18+
After running this command, the terminal will guide you with next steps. Follow [this page](/getting-started/prisma-postgres/from-the-cli) to complete the setup for your first Prisma Postgres project.
19+
20+
:::note
21+
If you need a database quickly for testing, or want to try out Prisma Postgres, you can run the following command to spin up a temporary 24-hour database:
22+
23+
```terminal
24+
npx create-db@latest
25+
```
26+
27+
You can learn more about `npx create-db` in [the dedicated documentation](/postgres/introduction/npx-create-db).
28+
:::
1829

1930
## Prisma ORM
2031

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
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

Comments
 (0)