This example shows how to add a Nexus api endpoint to a nextjs project. You can try out the deployed version right now here. For an overview of the state of Next.js integration with Nexus refer to the Next.js recipe.
-
Start a postgres database
db:start
-
Initialize your db schema
db:migrate
-
Source development environment variables (we use direnv)
direnv
-
Start nextjs dev mode
npm run dev
-
In another terminal start Nexus reflection to benefit from the type safety that Nexus can give you.
npm run nexus:reflection
-
Setup an account with Vercel
-
Provision a free postgres database with heroku
heroku create heroku addons:create heroku-postgresql
-
Copy the connection URL
heroku pg:credentials:url
-
Setup
DATABASE_URL
environment variable (add to all stages)now env add DATABASE_URL
-
From now on you can just deploy
npm run deploy:preview
-
When you are running Nexus' dev mode then Nexus will take care of migrating your development databse
-
To migrate the production database
now env pull
Export the
DATABASE_URL
into your shell.npm run db:migrate