Skip to content

Latest commit

 

History

History
78 lines (51 loc) · 1.49 KB

File metadata and controls

78 lines (51 loc) · 1.49 KB

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.

Setting up for development

  1. Start a postgres database

    db:start
    
  2. Initialize your db schema

    db:migrate
    
  3. Source development environment variables (we use direnv)

    direnv
    
  4. Start nextjs dev mode

    npm run dev
    
  5. In another terminal start Nexus reflection to benefit from the type safety that Nexus can give you.

    npm run nexus:reflection
    

Setting up for deployment

  1. Setup an account with Vercel

  2. Provision a free postgres database with heroku

    heroku create
    heroku addons:create heroku-postgresql
    
  3. Copy the connection URL

    heroku pg:credentials:url
    
  4. Setup DATABASE_URL environment variable (add to all stages)

    now env add DATABASE_URL
    
  5. From now on you can just deploy

    npm run deploy:preview
    

Migrations

  1. When you are running Nexus' dev mode then Nexus will take care of migrating your development databse

  2. To migrate the production database

    now env pull
    

    Export the DATABASE_URL into your shell.

    npm run db:migrate