This generator was bootstraped using create-prisma-generator
Prisma generator that generates CRUD operations based on your models, using Next.js.
- Minimal Next.js project with Server Actions enabled
- Prisma installed and configured
- Tailwind CSS Forms plugin
- Tailwind Merge for handling class merging
npm i -D prisma-next-crud-generator
generator client {
provider = "prisma-client-js"
}
generator next_crud {
provider = "npx prisma-next-crud-generator"
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Product {
id String @id @default(uuid())
name String
price Float
reallyLongDescription String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Note: id
, createdAt
, updatedAt
and deletedAt
fields are ignored by the generator in list pages and form inputs. The id
is used in the show
and edit
pages, supporting Int, BigInt and String types.
npx prisma generate
npm run dev
And you should see something like this:
That's it! You can now start playing with the generated app.
- Clone the repo
- Enter the generator directory:
cd packages/generator
- Run
npm run dev
to start the generator in watch mode - Open another terminal and enter the example directory:
cd packages/usage
- Run
npm run dev
to start the example in watch mode - Open
http://localhost:3000
and start playing with the example - Make your changes and run
npx prisma generate
to test your changes - Submit a PR