EdgeDB Next.js Starter

This guide helps you quickly start using EdgeDB with Next.js, providing a basic schema and UI. Here are some next steps to get you up to speed.

The result of the query SELECT random() * 10 is: 5.01487324319001
Modify the query in app/page.tsx to see the result of a different query.

Next Steps

  • Extend the EdgeDB schema

    Open the schema.esdl file and add your own types and fields. You can start by adding a Post type with a title and content field. For example:
    type Post {
      # Add your new fields here:
      required title: str;
      required content: str;
    }
  • Create and run a migration

    Run the following commands to create a new migration file and apply it:
    $ edgedb migration create
    $ edgedb migration apply
    
  • Generate TypeScript types

    Run the following command to generate TypeScript types for your schema:
    $ pnpm generate:all
    
  • Edit the EdgeDB query

    Open the app/page.tsx file and update the query to include your new type. For example:
    const postsQuery = e.select(e.Post, (_post) => ({
      id: true,
      title: true,
      content: true,
      // Add your other fields here
    }))
  • Deploy your app

    Once you're happy with your changes, you can deploy your app to the EdgeDB Cloud and Vercel. Follow the deployment instructions in the EdgeDB documentation.