Next.js 13 app directory support

6 Replies
ymc9
ymc92y ago
Hi @serraglia , thanks for bringing this up. Next.js 13's app folder has a different route handler API than the api routes in previous versions. It's not natively supported by ZenStack's nextjs server adapter yet.
ymc9
ymc92y ago
Fortunately it's not too hard to create a shim for it. I've put a sample project here: https://github.com/zenstackhq/docs-tutorial-nextjs-app-dir
GitHub
GitHub - zenstackhq/docs-tutorial-nextjs-app-dir: Tutorial for Next...
Tutorial for Next.js 13 with "app" directory. Contribute to zenstackhq/docs-tutorial-nextjs-app-dir development by creating an account on GitHub.
ymc9
ymc92y ago
The shim code is in "/src/app/api/model/[...path]/route.ts". It deals with the new route handler's API. The UI pages are still under "/src/pages" folder. I haven't got time to migrate them yet but it should be irrelevant to the problem. Moving forward we'll implement the "shim" in the ZenStack server adapter, and make it automatically adapted to the old and new Nextjs conventions. Hope the custom shim code works for you now, and let me know if you run into any issue. Btw, please make sure to update to the latest zenstack packages
Unknown User
Unknown UserOP2y ago
Message Not Public
Sign In & Join Server To View
ymc9
ymc92y ago
Hey @serraglia , thanks for the PR! I've left a comment there. Could you check when you get time to?
Unknown User
Unknown UserOP2y ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?