2026-03-29 11:43:23 +03:00
<!-- /index -->
2026-03-28 21:15:15 +03:00
# NextJS Style Guide
Rules and standards for NextJS and TypeScript development: architecture, typing, styles, components, API, and infrastructure.
## Documentation Structure
### Processes
**What to do** in a specific situation — step-by-step instructions.
| Section | Answers the question |
|---------|---------------------|
| Getting Started | What tools to install before starting development? |
| Creating an App | How to create a new project, where to get a template? |
| Creating Pages | How to add a page: routing and screen? |
| Creating Components | How to generate components using templates? |
| Styling | What to use: Mantine, tokens, or PostCSS? |
| Data Fetching | How to fetch data: SWR, codegen, sockets? |
| State Management | When and how to create a store (Zustand)? |
| Localization | How to add translations and work with i18next? |
### Basic Rules
**What the code should look like** — standards not tied to a specific technology.
| Section | Answers the question |
|---------|---------------------|
| Tech Stack | What stack do we use? |
| Architecture | How are FSD layers, dependencies, and public API structured? |
| Code Style | How to format code: indentation, quotes, imports, early return? |
| Naming | How to name files, variables, components, hooks? |
| Documentation | How to write JSDoc: what to document and what not? |
| Typing | How to type: type vs interface, any/unknown, FC? |
### Applied Sections
**How a specific area works** — rules, structure, and code examples for specific technologies and tools.
| Section | Answers the question |
|---------|---------------------|
| Project Structure | How are folders and files organized by FSD? |
| Components | How is a component structured: files, props, clsx, FC? |
2026-03-29 11:43:23 +03:00
| Page-level Components | How to define layout, page, loading, error, not-found? |
2026-03-28 21:15:15 +03:00
| Templates & Code Generation | How do templates work: syntax, variables, modifiers? |
| Styles | How to write CSS: PostCSS Modules, nesting, media, tokens? |
| Images | _(not filled)_ |
| SVG Sprites | _(not filled)_ |
| Video | _(not filled)_ |
| API | _(not filled)_ |
| Stores | _(not filled)_ |
| Hooks | _(not filled)_ |
| Fonts | _(not filled)_ |
| Localization | _(not filled)_ |
## For Assistants
Full documentation in a single MD file: https://gromlab.ru/docs/frontend-style-guide/raw/branch/main/generated/en/RULES.md
2026-03-29 11:43:23 +03:00
<!-- /workflow/getting - started -->
## Getting Started
2026-03-28 21:15:15 +03:00
Setting up the environment and installing tools before starting development.
2026-03-29 11:43:23 +03:00
<!-- /workflow/creating - app -->
## Creating an App
2026-03-28 21:15:15 +03:00
How to create a new application: choosing a project template and initialization.
2026-03-29 11:43:23 +03:00
<!-- /workflow/creating - pages -->
## Creating Pages
2026-03-28 21:15:15 +03:00
Page creation pattern: routing (page.tsx) and screen.
2026-03-29 11:43:23 +03:00
<!-- /workflow/creating - components -->
## Creating Components
2026-03-28 21:15:15 +03:00
Generating components using templates, working with child components.
2026-03-29 11:43:23 +03:00
<!-- /workflow/styling -->
## Styling
2026-03-28 21:15:15 +03:00
Styling tools priority and rules for their application.
2026-03-29 11:43:23 +03:00
<!-- /workflow/data - fetching -->
## Data Fetching
2026-03-28 21:15:15 +03:00
How to fetch data: SWR, API client codegen, sockets.
2026-03-29 11:43:23 +03:00
<!-- /workflow/state - management -->
## State Management
2026-03-28 21:15:15 +03:00
When and how to create a store (Zustand), what to store locally vs globally.
2026-03-29 11:43:23 +03:00
<!-- /workflow/localization -->
## Localization
2026-03-28 21:15:15 +03:00
How to add translations and work with i18next.
2026-03-29 11:43:23 +03:00
<!-- /basics/tech - stack -->
## Tech Stack
2026-03-28 21:15:15 +03:00
Base technology stack and libraries used in projects.
2026-03-29 11:43:23 +03:00
<!-- /basics/architecture -->
## Architecture
2026-03-28 21:15:15 +03:00
Architecture based on FSD (Feature-Sliced Design) and strict module boundaries.
2026-03-29 11:43:23 +03:00
<!-- /basics/code - style -->
## Code Style
2026-03-28 21:15:15 +03:00
Unified code formatting rules: indentation, line breaks, quotes, import order, and readability.
2026-03-29 11:43:23 +03:00
<!-- /basics/naming -->
## Naming
2026-03-28 21:15:15 +03:00
Naming should be predictable, concise, and reflect the meaning of the entity.
2026-03-29 11:43:23 +03:00
<!-- /basics/documentation -->
## Documentation
2026-03-28 21:15:15 +03:00
Documentation should help understand the purpose of an entity, not duplicate its types or obvious details.
2026-03-29 11:43:23 +03:00
<!-- /basics/typing -->
## Typing
2026-03-28 21:15:15 +03:00
Typing is required for all public interfaces, functions, and components.
2026-03-29 11:43:23 +03:00
<!-- /applied/project - structure -->
## Project Structure
2026-03-28 21:15:15 +03:00
Base project structure and principles of module organization at folder and file level.
2026-03-29 11:43:23 +03:00
<!-- /applied/components -->
## Components
2026-03-28 21:15:15 +03:00
Rules for creating UI components across all FSD layers.
2026-03-29 11:43:23 +03:00
<!-- /applied/page - level -->
## Page-level Components
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
Next.js App Router special files used by the framework by convention: `layout.tsx` , `page.tsx` , `loading.tsx` , `error.tsx` , `not-found.tsx` , `template.tsx` .
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/templates - generation -->
## Templates & Code Generation
2026-03-28 21:15:15 +03:00
Template tools, syntax, and examples for code generation.
2026-03-29 11:43:23 +03:00
<!-- /applied/styles -->
## Styles
2026-03-28 21:15:15 +03:00
CSS writing rules: PostCSS Modules, nesting, media queries, variables, formatting.
2026-03-29 11:43:23 +03:00
<!-- /applied/images - sprites -->
## Images
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/svg - sprites -->
## SVG Sprites
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/video -->
## Video
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/api -->
## API
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/stores -->
## Stores
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/hooks -->
## Hooks
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/fonts -->
## Fonts
2026-03-28 21:15:15 +03:00
2026-03-29 11:43:23 +03:00
<!-- /applied/localization -->
## Localization