React Stack
A React frontend takes one of three rendering modes, chosen by who reads it: a static application for an authenticated console, server rendering for a public surface a user reaches by link or search, and one static page with no router for a device client. A team opening a React frontend chooses the mode under Web Rendering before writing routes, and finds on this page the names, files, and libraries the shared web pages leave to this stack. The shared stack rules in Technology Stacks apply to every stack.
On this page
Concepts#
Version Pins#
The stack.node key in litespec.manifest.yaml pins the Node version, the stack.pnpm key pins pnpm, and the packages.npm keys pin every npm package version. These keys name the pins; the manifest holds the values.
Structure Bindings#
React names the three frontend parts as folders: src/app for the frame, src/routes for the addresses, and src/modules for the use-case code. The router generates the typed route tree from the files under src/routes. Shared files use the .tsx extension.
Rendering Bindings#
A React route is a file under src/routes that uses the router file convention, and the router builds the typed route tree from it. A shell is a pathless layout route whose file name starts with an underscore. Server-only code lives in a file whose name and import show the server ownership.
Component Bindings#
A class or style binding spells the className or style prop. A drawing that no composite makes lives in a visual file. Raw HTML is the dangerouslySetInnerHTML prop. The route error surface is the route error component, which draws the shared problem state. Component authoring follows Frontend Components and TypeScript Web Components. The page-code lint enforces the refusals of TypeScript Web Components in route and module folders.
Route Entry Bindings#
A route entry is one file under src/routes that declares a route for an address. Pathless layout routes, error components, and route groups are not route entries, so they hold no screen mark.
Data Bindings#
Route data lives in the query cache. A component's own state is local component state. The shared package's form entry point is its form hook, and the locale-dictionary contract is stated in Web Data and State.
Testing Bindings#
The mocks rule names the libraries a test must not replace.
UI Bindings#
The shadcn/ui registry is built with the shadcn CLI, pinned in the manifest as shadcn. The state-to-tone table maps each application state to one tone.
Standards#
Keep the React Frame, Routes, and Modules#
rulerequiredguidancelitespec/frontend/web/react/stack#keep-the-react-frame-routes-and-modulesA React frontend MUST hold the frame in src/app, one file per address in src/routes, and the use-case code in src/modules.
Applies toartifact: any
Why
Three fixed homes let a reader and a tool find the frame, the routes, and the use-case code in the same place in every React frontend.
Example
In the library product, the frame sits in src/app, the loan list route is src/routes/loans.tsx, and the loan use-case code sits in src/modules/loans.
Checka reviewer answers
Reviewed forWhich files under src sit outside src/app, src/routes, and src/modules, or which address has two files under src/routes? Look at the src tree of each React frontend.
Marked guidance: a reviewer answers this question.
Use the TSX Extension on Shared Files#
rulerequiredguidancelitespec/frontend/web/react/stack#use-the-tsx-extension-on-shared-filesA shared React file MUST use the .tsx extension.
Applies toartifact: any
Why
One extension lets the compiler, the lint, and a search treat every shared React file the same way.
Example
In the library product, the shared loan status helper is src/app/loan-status.tsx.
Checka reviewer answers
Reviewed forWhich shared React files use an extension other than .tsx? Look at the src tree of each React frontend.
Marked guidance: a reviewer answers this question.
Hold a Route's Parts in Its Route File#
rulerequiredguidancelitespec/frontend/web/react/stack#hold-a-routes-parts-in-its-route-fileA route file MUST hold its search parameters, its loader, and its component.
Applies toartifact: route
Why
One file for the three parts lets a reader see an address, its inputs, its data, and its screen together.
Example
The library loan list route file holds its page number, its loader, and its component.
Checka reviewer answers
Reviewed forWhich route files keep their search parameters, loader, or component in another file? Look at each file under src/routes.
Marked guidance: a reviewer answers this question.
Declare Route Search Parameters in validateSearch#
rulerequiredguidancelitespec/frontend/web/react/stack#declare-route-search-parameters-in-validatesearchA route MUST declare its search parameters in validateSearch.
Applies toartifact: route
Why
A declared check runs before the route reads a parameter, so the route receives a typed value or a refusal.
Example
The library loan list route declares its page number in validateSearch.
Checka reviewer answers
Reviewed forWhich routes read a search parameter without declaring it in validateSearch? Look at each route file under src/routes.
Marked guidance: a reviewer answers this question.
Prefetch Route Reads in the Loader#
rulerequiredguidancelitespec/frontend/web/react/stack#prefetch-route-reads-in-the-loaderA route MUST prefetch its reads in its loader.
Applies toartifact: route
Why
A loader fills the query cache before the component draws, so the first render has its data.
Example
The library loan list loader fetches the loan page for the page number that validateSearch checked.
Checka reviewer answers
Reviewed forWhich routes read data in their component without a loader prefetch? Look at each loader under src/routes.
Marked guidance: a reviewer answers this question.
Read Route Data with useSuspenseQuery#
rulerequiredguidancelitespec/frontend/web/react/stack#read-route-data-with-usesuspensequeryA route file MUST read its route data with useSuspenseQuery over the key its loader filled.
Applies toartifact: route
Why
Reading the filled key keeps the component on the data the loader fetched.
Example
The library loan list component reads its page with useSuspenseQuery over the same key the loader filled.
Checka reviewer answers
Reviewed forWhich route data reads use another query hook or a key the loader does not fill? Look at each route file under src/routes.
Marked guidance: a reviewer answers this question.
Load Intent Targets Before Navigation#
rulerequiredguidancelitespec/frontend/web/react/stack#load-intent-targets-before-navigationIntent preloading MUST fill the query cache before navigation.
Applies toartifact: route
Why
A preload on hover or focus fills the cache before the click, so the target route draws from data it already holds.
Example
Hovering the loan link fills the loan page key, so the click draws the loan list from the cache.
Checka reviewer answers
Reviewed forWhich links preload a route without filling the query cache? Look at the router link setup in the src tree.
Marked guidance: a reviewer answers this question.
Use Named Props for Class and Style Bindings#
rulerequiredguidancelitespec/frontend/web/react/stack#use-named-props-for-class-and-style-bindingsA class or style binding in a React component MUST use className or style.
Applies toartifact: component
Why
Two fixed prop names keep styling in one vocabulary that the lint and a reviewer can read.
Example
The loan row in src/app/components/LoanRow.tsx sets its tone through className and sets no style prop.
Checka reviewer answers
Reviewed forWhich React components bind a class or style through another prop? Look at the JSX in the component files.
Marked guidance: a reviewer answers this question.
Name Drawings with the Visual Suffix#
rulerequiredguidancelitespec/frontend/web/react/stack#name-drawings-with-the-visual-suffixA file that holds a drawing no composite makes MUST end with .visual.tsx.
Applies toartifact: component
Why
The suffix marks the one place outside the composites, so a search finds every custom drawing in one pass.
Example
The library loan due-date sparkline is LoanSparkline.visual.tsx.
Checka reviewer answers
Reviewed forWhich custom drawings sit in .tsx files whose names lack the .visual.tsx suffix? Look in the component folders.
Marked guidance: a reviewer answers this question.
Render Raw HTML Only Through dangerouslySetInnerHTML#
rulerequiredguidancelitespec/frontend/web/react/stack#render-raw-html-only-through-dangerouslysetinnerhtmlA React component MUST pass raw HTML to the page only through dangerouslySetInnerHTML.
Applies toartifact: component
Why
One named prop makes every raw HTML sink a name a search finds, and a review can check each use.
Example
The library loan note renders its sanitized HTML through dangerouslySetInnerHTML after its recorded sanitization decision.
Checka reviewer answers
Reviewed forWhich React components write raw HTML through another prop or API? Look for innerHTML and raw markup in the component files.
Marked guidance: a reviewer answers this question.
Show Route Failure in the Route Error Component#
rulerequiredguidancelitespec/frontend/web/react/stack#show-route-failure-in-the-route-error-componentA route failure MUST render in the route error component, which draws the shared problem state.
Applies toartifact: route
Why
One error component gives every route failure the same problem state and the same recovery.
Example
A library loan list that fails to load shows the shared problem state with its trace identifier.
Checka reviewer answers
Reviewed forWhich route failures render outside the route error component? Look at the error handling of each route under src/routes.
Marked guidance: a reviewer answers this question.
Apply the Page-Code Lint to Route and Module Code#
rulerequiredguidancelitespec/frontend/web/react/stack#apply-the-page-code-lint-to-route-and-module-codeThe page-code lint MUST apply import restrictions and JSX element restrictions in route and module folders, with visual files allowlisted.
Applies toartifact: any
Why
A lint refusal that names the composite to use lets the author replace a raw element when writing it, not in review.
Example
The lint refuses a raw div in src/routes/loans.tsx and names the Stack composite to use instead.
Checka reviewer answers
Reviewed forWhich route or module files use a refused import or JSX element without a lint finding? Run the page-code lint, then compare its findings with the files under src/routes and src/modules.
Marked guidance: a reviewer answers this question.
Mark Each React Route Entry with Its Screen#
rulerequiredguidancelitespec/frontend/web/react/stack#mark-each-react-route-entry-with-its-screenA route entry MUST export its screen mark from its route file as the same typed constant a use-case module exports.
Applies toartifact: route
Why
A mark in the route file ties the address to its use case where the address is declared, so the builder and the check read one link.
Example
The library loan list route file exports the typed screen mark for the loan list screen.
Checka reviewer answers
Reviewed forWhich route entries export no screen mark from their route file? Look at each route file under src/routes.
Marked guidance: a reviewer answers this question.
Keep Layouts, Error Components, and Route Groups Unmarked#
rulerequiredguidancelitespec/frontend/web/react/stack#keep-layouts-error-components-and-route-groups-unmarkedA pathless layout route, an error component, or a route group MUST NOT carry a screen mark.
Applies toartifact: route
Why
A layout, an error component, or a group draws no screen of its own, so a mark on it ties an address to a screen it does not show.
Example
The underscore layout route in the library product exports no screen mark.
Checka reviewer answers
Reviewed forWhich layout routes, error components, or route groups export a screen mark? Look at the non-entry files under src/routes.
Marked guidance: a reviewer answers this question.
Add the TanStack Query Plugin to the Client Generator#
rulerequiredguidancelitespec/frontend/web/react/stack#add-the-tanstack-query-plugin-to-the-client-generatorThe client generator MUST add the @tanstack/react-query plugin.
Applies toartifact: any
Why
The plugin gives every generated read a query key, so the cache entries of every route share one shape.
Example
The library product's client generator adds the @tanstack/react-query plugin, so each generated loan read has a query key.
Checka reviewer answers
Reviewed forWhich client generator configurations omit the @tanstack/react-query plugin? Look in the generator configuration of each React frontend.
Marked guidance: a reviewer answers this question.
Meet the Locale-Dictionary Contract with the Dictionary Library#
rulerequiredguidancelitespec/frontend/web/react/stack#meet-the-locale-dictionary-contract-with-the-dictionary-libraryThe dictionary library MUST meet the locale-dictionary contract that the web data page states.
Applies toartifact: any
Why
One contract keeps every sentence in one dictionary per language, with the same fill, plural, and fallback behavior.
Example
The library product resolves its overdue-loan sentence through its dictionary library in every language it ships.
Checka reviewer answers
Reviewed forWhich copy bypasses the dictionary library, or misses fill, plural, typed keys, or a declared fallback? Look at the copy call sites under src.
Marked guidance: a reviewer answers this question.
Use the Shared Package Form Hook#
rulerequiredguidancelitespec/frontend/web/react/stack#use-the-shared-package-form-hookA React form MUST build on the form hook of the shared package.
Applies toartifact: form
Why
One entry point gives every form the same field wiring and the same display for a refusal on its field.
Example
The library loan request form uses the shared form hook and no form library of its own.
Checka reviewer answers
Reviewed forWhich React forms bypass the shared package form hook? Look at the form files under src.
Marked guidance: a reviewer answers this question.
Keep React Test Mocks to the Owned Libraries#
rulerequiredguidancelitespec/frontend/web/react/stack#keep-react-test-mocks-to-the-owned-librariesA test MUST NOT replace the rendering library, the router, or the query library.
Applies toartifact: test
Why
Those three are the stack's own behavior, and a stand-in for any of them tests the stand-in instead of the screen.
Example
The library loan list route test renders with the real router and query library and replaces only the network call.
Checka reviewer answers
Reviewed forWhich tests replace the rendering library, the router, or the query library? Look at the mocks in each test file.
Marked guidance: a reviewer answers this question.
Run the Registry Build Command#
rulerequiredguidancelitespec/frontend/web/react/stack#run-the-registry-build-commandThe registry build command MUST be shadcn build.
Applies toartifact: any
Why
One registry command builds UI artifacts the same way in every React frontend.
Example
The library product builds its registry with shadcn build.
Checka reviewer answers
Reviewed forWhich registry build scripts run a command other than shadcn build? Look at the scripts in each frontend's package.json.
Marked guidance: a reviewer answers this question.
Keep the Tone Table in One States File#
rulerequiredguidancelitespec/frontend/web/react/stack#keep-the-tone-table-in-one-states-fileThe state-to-tone table MUST live in src/app/states.tsx.
Applies toartifact: any
Why
One file holds every state's tone, so a state reads the same tone on every route.
Example
The library product maps the overdue state to its warning tone in src/app/states.tsx.
Checka reviewer answers
Reviewed forWhich state-to-tone mappings live outside src/app/states.tsx? Look for tone maps in the src tree.
Marked guidance: a reviewer answers this question.
Conventions#
None.