keystonejs / keystonejs/keystone

Bug in default example for NextJS App Router

Open
#9,298 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
19h 14m
Merged PRs (30d)
19

Description

https://github.com/keystonejs/keystone/tree/main/examples/framework-nextjs-app-directory

The build functions for the NextJS app router example are not functioning as expected when cloned from GitHub. When you attempt to build the Keystone interface, it will not compile the GraphQL files, as the script expects the 'pages' file to be located within an 'admin' directory at the root of the project, instead of located within the ~/src/pages/api/[arbitrary routes or pages for the Keystone admin view here].

The build will pick up the GraphQL endpoint as it should when the files are moved to the base directory, but wrapped inside of the admin directory.

![image](https://github.com/user-attachments/assets/0bf2a045-16af-4eed-87ab-a8c80dcbcd76)

I've also placed the NextAuth module there, to demonstrate how I figured out this process, and for how future users can embed NextAuth into Keystone using the App Router.

Build error will occur on all versions, it's a problem with file structure.

Contributor guide

Open the contributing guide

Research direction

Start with the example at examples/framework-nextjs-app-directory and reproduce the build using its current file structure. Inspect how the build locates GraphQL files under ~/src/pages/api versus an admin directory; done means the Keystone interface builds successfully with the App Router layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, nextjs
Domain
build-system, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.