Co-authored by
EdgeDB is an open-source Postgres data layer designed to address major ergonomic SQL and relational schema modeling limitations while improving type safety and performance.
JTBDOS
uses Neon as the database provider with Prisma as the ORM as well as Clerk for authentication. This guide will provide the steps you need to switch the database provider from Neon to EdgeDB.
For authentication, another guide will be provided to switch to EdgeDB Auth with access policies, social
auth providers, and more.
JTBDOS
project.
1. Create a new EdgeDB database
Create an account at EdgeDB Cloud. Once done, create a new instance (you can use EdgeDB’s free tier). We’ll later connect to it through the EdgeDB CLI.2. Swap out the required dependencies in @repo/database
Uninstall the existing dependencies…
Terminal
Terminal
3. Setup EdgeDB in @repo/database
package
In the @repo/database
directory, run:
Terminal
Replace
<org_name>
and <instance_name>
with the EdgeDB’s organization and instance you’ve previously created in the EdgeDB Cloud.init
command creates a new subdirectory called dbschema
, which contains everything related to EdgeDB:
prisma/
directory from the @repo/database
:
Terminal
4. Update the database connection code
Update the database connection code to use an EdgeDB client:packages/database/index.ts
5. Update the schema file and generate types
Now, you can modify the database schema:dbschema/default.esdl
Terminal
Terminal
dbschema
directory.
6. Update your queries
Now you can update your queries to use the EdgeDB client. For example, here’s how we can update thepage
query in app/(authenticated)/page.tsx
:
app/(authenticated)/page.tsx
7. Replace Prisma Studio with EdgeDB UI
You can also delete the now unused Prisma Studio app located atapps/studio
:
Terminal
Terminal
8. Extract EdgeDB environment variables for deployment
When deploying your app, you need to provide theEDGEDB_SECRET_KEY
and EDGEDB_INSTANCE
environment variables in your app’s cloud provider to connect to your EdgeDB Cloud instance.
You can generate a dedicated secret key for your instance with npx edgedb cloud secretkey create
or via the web UI’s “Secret Keys” pane in your instance dashboard.