zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

Change next.js app dir sample project to be entirely using "app" dir #775

Closed ymc9 closed 10 months ago

PhilGarb commented 11 months ago

Is this just related to the example in the docs or is there no current support for the app dir? I tried to adopt zenstack and have seen issues with resolving of the generated output. I made a small repro here: https://github.com/PhilGarb/my-blog-app. This is just following the guide and replacing the pages directory with the app directory.

When visiting the single available page: Error: Model meta cannot be loaded. Please make sure "zenstack generate" has been run. is thrown. I have run the generation like described in the guide.

Let me know if this is the wrong place and I will create another issue.

ymc9 commented 11 months ago

Is this just related to the example in the docs or is there no current support for the app dir? I tried to adopt zenstack and have seen issues with resolving of the generated output. I made a small repro here: https://github.com/PhilGarb/my-blog-app. This is just following the guide and replacing the pages directory with the app directory.

When visiting the single available page: Error: Model meta cannot be loaded. Please make sure "zenstack generate" has been run. is thrown. I have run the generation like described in the guide.

Let me know if this is the wrong place and I will create another issue.

Hi @PhilGarb , app dir is supported, it's just the sample project hasn't migrated the page UI components yet. Here's the code: https://github.com/zenstackhq/docs-tutorial-nextjs-app-dir

Please note that you need to exclude @zenstackhq/runtime package from nextjs's server component bundler. Please take a look at next.config.msj file.

PhilGarb commented 11 months ago

Thank you so much! The hint with the next.config property worked for me.

ymc9 commented 11 months ago

Thank you so much! The hint with the next.config property worked for me.

Cool. I submitted a PR a while ago to next.js to make it built-in but hasn't been accepted ...