Skip to content

React guide

Structuring a React Project That Stays Maintainable

React projects rarely fail because the first component was wrong. They fail because the structure never caught up with the product. A small amount of planning around routes, boundaries and state ownership prevents most of the usual mess.

Guide details

7 minute read
Updated 13 November 2026

This guide is general technical information. It is not a guarantee of a particular result on your hosting, data or project.

Discuss your project

Start with routes and boundaries

Map the routes before building components. Each route should have an obvious page component and a clear data requirement. Shared layout belongs in a layout component; page-specific composition stays with the page.

Decide where a feature begins and ends. A feature can own its components, hooks and types. Shared primitives such as buttons, fields and cards live outside features so they can be reused without creating circular dependencies.

  • One page component per route
  • Layout separated from page content
  • Feature folders for domain-specific code
  • Shared UI primitives kept independent

Components, hooks and state

Keep components focused on rendering. Move reusable behaviour into hooks, but do not turn every piece of logic into an abstraction. State should live close to where it is used; lift it only when another part of the tree genuinely needs it.

Separate server state from interface state. Data fetched from an API is not the same as whether a menu is open. Treating them as one store is a common source of bugs and unnecessary re-renders.

  • Local state by default, lifted only when needed
  • Server data and UI state kept distinct
  • Effects reserved for external synchronisation
  • Derived values computed rather than stored twice

Data fetching and API contracts

Type the API response at the boundary and validate it before the UI trusts it. Handle loading, empty, error and success states explicitly. A spinner that never resolves is usually a missing error path, not a styling problem.

Keep request functions in one place so the components do not each invent their own fetch logic. When the API changes, the contract and its consumers should be easy to find.

  • Typed request and response shapes
  • Explicit loading, empty, error and success states
  • Centralised API functions
  • No secrets or privileged calls in the browser

Testing and review

Test the behaviour that would be expensive to break: authentication, permissions, forms, payments and critical navigation. Component tests are useful for interaction patterns; end-to-end tests cover the journeys that cross pages.

Review the structure as the product grows. If a feature folder becomes a second application, split it. If shared code changes for every page, it may not be shared after all.

  • Critical flows covered by tests
  • Accessibility checked with keyboard and screen reader
  • Build and bundle size reviewed regularly
  • Structure revisited when features grow

Key takeaways

  • Plan routes and feature boundaries before components multiply.
  • Keep server state and interface state separate.
  • Handle loading, empty and error states as part of the feature.
  • Test the flows that would be expensive to break.

Need help

Related services.

Questions

About this guide.

Should every component have its own folder?

No. A folder per component creates a lot of noise. Group by feature, keep small components beside their parent, and extract shared primitives when reuse is real.

Do I need a state management library?

Not by default. Local state and a small amount of context cover many applications. Add a library when the state is genuinely shared, complex and difficult to reason about without one.

How do you decide between client and server rendering?

It depends on the product. Server rendering helps with first paint and search visibility; client rendering suits application interfaces behind authentication. The choice is made before the build, not after.

Next step

Tell me what you are building, and what is getting in the way.

A short brief is enough to start. You will get clear questions, a practical scope and an honest answer about fit.

A small note about cookies

Essential storage keeps preferences and security working. Analytics stays off unless you allow it and a measurement ID has been configured. Read the cookie policy.