Skip to content

React / Next.js

Editor
Engineering leadership

Engineers on a React / Next.js project.

When you write or review frontend web code.

  • Must: Follow Engineering for Git, review, tests-in-general, and Delivery. This page adds only React / Next.js rules.
  • Must: Server Components vs Client Components is an explicit choice. Mark 'use client' only when the component needs browser APIs, state, or event handlers. Do not make the whole tree a client tree by default.
  • Must: Data fetching and mutations go through the app’s agreed path (server fetch, route handlers, or a named client layer). Do not scatter ad-hoc fetch calls with copied auth headers.
  • Must: Do not ship secrets, private env values, or unscoped service keys to the browser. Public env must be prefixed the way Next.js requires for that project.
  • Should: Colocate route files the way the App Router (or this repo’s Pages Router) already does. Do not mix both routers in one app without a decision record.
  • Should: Keep client state local when it is local. Lift to a shared store only when several distant trees need the same data.
  • Should: Cover user-visible behavior with component or Playwright/Cypress tests for the risky paths (auth, checkout, forms). See Automated tests.
  • Team decides: Next.js version, styling system, and data library (if any). Record them in the README.

A reviewer can see which tree is server vs client, where data is loaded, and how a user-facing path is tested — without a live walkthrough.

  1. Check Git and review on the shared pages first.
  2. Place the UI in the existing route structure. Prefer server by default.
  3. Load data on the server when you can; mutate through the agreed API layer.
  4. Add or update a UI test for the behavior you changed.
  5. Check the bundle for accidental client-only secrets before you ask for review.