Nuxt 3


For database access supastarter integrates Prisma (opens in a new tab).


Why Prisma:
Prisma is a modern and powerful database toolkit. By simply creating a schema.prisma file, you can define your data model and Prisma will generate a completely type-safe and ready-to-use query builder for you to use in your application. It supports all major databases and having a generic schema enables you to easily switch between them, if you need to.
With the latest version of Prisma, it also became a lot smaller in size and faster in performance, which makes it work great in serverless environments.

Update your schema

To update your database schema, you can simply edit the schema.prisma file in the /packages/database library. You can find more information about the Prisma schema file here (opens in a new tab).

To add an entity for "posts" for example, you can add the following to your schema:

model Post {
  id        String      @id @default(cuid())
  title     String
  content   String
  author    User     @relation(fields: [authorId], references: [id])
  authorId  String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

Push your changes to the database

To push your changes to the database, you can run the following command:

pnpm db:push

Generate prisma client

After you have pushed your schema changes, you need to re-generate the prisma client. You can do this by running the following command:

pnpm db:generate