A Next.js + React Query starter focused on clean layering:
appis route entry only.uiis page/component implementation.apicontains request functions.hooksis the only client-facing API call layer.
- Node.js
>= 20 - pnpm
>= 9
For local maintainers:
pnpm dev
pnpm build
pnpm start
pnpm lint
pnpm typecheck
pnpm test
pnpm test:watch
pnpm test:coverageAgents should follow AGENTS.md command restrictions instead of running project scripts directly.
Vitest covers functions and API behavior only. UI pages, React components, browser behavior, and
jsdom are outside the current test scope.
Tests are colocated with the source module in a nested test/ directory:
src/
configs/
validator/
validate-server-env.ts
test/
validate-server-env.test.ts
api/
time/
query/
get-server-time.ts
test/
get-server-time.test.ts
Keep one test file focused on the matching source module. Use pnpm test for a one-time local or
CI run, pnpm test:watch while developing, and pnpm test:coverage to inspect coverage.
src/
app/ # Next.js route entries (thin layer)
ui/ # UI implementation (pages + shared components)
api/ # Request functions by domain (query/mutation/types)
hooks/ # Hooks layer (React Query wrappers over src/api)
configs/ # Client/server environment config
lib/ # Infrastructure layer (errors/http/runtime/utils)
styles/ # Global style entry, shadcn base css, fonts
- Client page components must not call network requests directly.
- Client pages/components call hooks in
src/hooks. - Hooks call request functions in
src/api. src/apiuses wrapped ky request helpers only:apiRequestforsrc/app/api/**endpointshttpRequestfor non-src/app/api/**endpoints
src/appshould stay minimal and route-focused; page implementation lives insrc/ui/app.
AGENTS.md: Agent-specific command, code style, and workflow instructions.agents/skills/*/SKILL.md: Modular agent conventions for project layers.agents/skills/testing-conventions/SKILL.md: Function and API testing conventionssrc/app/README.md: App Router entry-layer conventionssrc/ui/README.md: UI structure and component organizationsrc/api/README.md: API request layer rulessrc/hooks/README.md: Hook layer and React Query conventionssrc/configs/README.md: Env validation and client/server config boundariessrc/lib/README.md: Infrastructure modules and change policysrc/styles/README.md: Style entry and CSS extension rules