DEV Community

Cover image for Introducing ZenStack: a schema-first toolkit for creating CRUD services in Next.js projects
ymc9 for ZenStack

Posted on • Updated on

Introducing ZenStack: a schema-first toolkit for creating CRUD services in Next.js projects


Next.js is evolving fast to become an increasingly appealing choice for building full-stack web apps. However, coding up the backend part of an app, especially implementing CRUD services efficiently and securely, is still tricky (and boring 😒 too).

ZenStack is a toolkit that simplifies the construction of CRUD services with a schema-first approach. It offers a modeling language for defining data models, relations, and access policies and then generates RESTful CRUD services (with authorization) and React hooks for you. It also allows you to share types between client and server-side coding and achieve end-to-end type safety without pain.

Our goal is to let you save time writing boilerplate code and focus on building what matters - the user experience.

If it feels relevant, please also check out the excellent detailed tutorial by @jiasheng for how to use it in action:

, or find more details directly at Github:

GitHub logo zenstackhq / zenstack

Supercharges Prisma ORM with a powerful access control layer and unlocks its full potential for web development.

What it is

ZenStack is a toolkit that simplifies the development of a web app's backend. It supercharges Prisma ORM with a powerful access control layer and unleashes its full potential for web development.

Our goal is to let you save time writing boilerplate code and focus on building real features!

How it works

ZenStack extended Prisma schema language for supporting custom attributes and functions and, based on that, implemented a flexible access control layer around Prisma.

// schema.zmodel

model Post {
    id String @id
    title String
    published Boolean @default(false)
    author User @relation(fields: [authorId], references: [id])
    authorId String

    // 🔐 allow logged-in users to read published posts
    @@allow('read', auth() != null && published)

    // 🔐 allow full CRUD by author
    @@allow('all', author == auth())
}
Enter fullscreen mode Exit fullscreen mode

At runtime…

Also, join us on discord for chat and the latest updates!

Have fun!

Top comments (0)