prisma-next-crud-generator
v1.3.0
Published
Generate CRUD operations for Next.js from Prisma schema
Downloads
44
Maintainers
Readme
Prisma Next CRUD Generator
This generator was bootstraped using create-prisma-generator
Prisma generator that generates CRUD operations based on your models, using Next.js.
Requirements
- Prisma
- Next.js with Server Actions enabled
- Tailwind CSS Forms plugin
- Tailwind Merge for handling class merging
How to use it?
1. Install the generator
npm i -D prisma-next-crud-generator
2. Add the generator to your Prisma schema and add some models
generator client {
provider = "prisma-client-js"
}
generator next_crud {
provider = "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.
3. Run npx prisma generate
npx prisma generate
4. Run npm run dev
npm run dev
5. Open http://localhost:3000
And you should see something like this:
That's it! You can now start playing with the generated app.
How to contribute?
- Go to the repository and clone it
- 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