You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React-admin is a comprehensive frontend framework for building B2B and admin applications on top of REST/GraphQL APIs, using TypeScript, React, and Material UI. It's an open-source project maintained by Marmelab that provides a complete solution for B2B applications with data-driven interfaces.
4
4
5
-
## Architecture & Design Patterns
6
-
7
-
### Key Principles
5
+
## Design Principles
8
6
9
7
- Designed for Single-Page Application (SPA) architecture
10
-
- Provider-based abstraction for data fetching, auth, and i18n
11
-
- "Batteries included but removable" - everything is replaceable
12
-
- User Experience and Developer Experience are equally important
13
-
- Backward compatibility prioritized over new features
14
-
- Composition over Configuration - Use React patterns, not custom DSLs
15
-
- Minimal API Surface - If it can be done in React, don't add to core
16
-
- Standing on Giants' Shoulders - Use best-in-class libraries, don't reinvent the wheel
17
-
18
-
### Provider Pattern
19
-
20
-
React-admin uses adapters called "providers" for external integrations:
21
-
22
-
```typescript
23
-
// Data Provider - abstracts API calls
24
-
dataProvider.getList('posts', {
25
-
pagination: { page: 1, perPage: 5 },
26
-
sort: { field: 'title', order: 'ASC' },
27
-
filter: { author_id: 12 }
28
-
})
29
-
30
-
// Auth Provider - handles authentication
31
-
authProvider.checkAuth()
32
-
authProvider.login({ username, password })
33
-
authProvider.getPermissions()
34
-
35
-
// i18n Provider - manages translations
36
-
i18nProvider.translate('ra.action.save')
37
-
```
38
-
39
-
### Hook-Based API
40
-
41
-
All functionality exposed through hooks following React patterns:
The `ra-core` package contains all logic without UI. UI components are in separate packages like `ra-ui-materialui`. This allows:
61
-
62
-
- Custom UIs using core hooks and controllers
63
-
- Swapping UI libraries without changing core logic
8
+
- Backward compatibility over new features — avoid breaking changes
9
+
- Minimal API surface — if it can be done in a few lines of React, don't add it to core
10
+
- Provider pattern — data fetching, auth, and i18n are abstracted behind swappable provider adapters (`dataProvider`, `authProvider`, `i18nProvider`)
11
+
- Headless core — `ra-core` contains all logic without UI; `ra-ui-materialui` provides the Material UI layer. This separation is intentional — don't couple logic to UI
12
+
- Controller-view separation — controllers in `ra-core/src/controller/` expose business logic via hooks; views in `ra-ui-materialui/src/` handle rendering
13
+
- Context: pull, don't push — components expose data to descendants via context + custom hooks, not prop drilling. Every component that fetches data or defines callbacks creates a context for it
14
+
-`useEvent()` internal hook — use this for memoized event handlers instead of `useCallback`
64
15
65
-
### Controller-View Separation
16
+
##Anti-Patterns
66
17
67
-
- Controllers in `ra-core/src/controller/` handle business logic
68
-
- Views in `ra-ui-materialui/src/` handle rendering
69
-
- Controllers provide data and callbacks via hooks
70
-
71
-
### Context: Pull, Don’t Push
72
-
73
-
Communication between components can be challenging, especially in large React applications, where passing props down several levels can become cumbersome. React-admin addresses this issue using a pull model, where components expose props to their descendants via a context, and descendants can consume these props using custom hooks.
74
-
75
-
Whenever a react-admin component fetches data or defines a callback, it creates a context and places the data and callback in it.
18
+
- No `React.cloneElement()` — it breaks composition
19
+
- No children inspection — violates React patterns (exception: Datagrid)
20
+
- No features achievable in pure React — keep the API surface small
21
+
- No comments when code is self-explanatory
76
22
77
23
## Codebase Organization
78
24
79
-
### Monorepo Structure
80
-
81
25
```
82
26
react-admin/
83
27
├── packages/ # Lerna-managed packages
@@ -98,16 +42,7 @@ react-admin/
98
42
└── scripts/ # Build scripts
99
43
```
100
44
101
-
### Key ra-core Directories
102
-
103
-
-`src/auth/` - Authentication and authorization (54 files)
104
-
-`src/controller/` - CRUD controllers and state management
105
-
-`src/dataProvider/` - Data fetching and caching logic (70 files)
106
-
-`src/form/` - Form handling (31 files)
107
-
-`src/routing/` - Navigation and routing (26 files)
1.**Composition over configuration** - Use React composition patterns
142
-
2.**Smart defaults** - Components should work out-of-the-box
143
-
3.**Controlled and uncontrolled** modes supported
144
-
4.**Props pass-through** - Spread additional props to root element
145
-
146
-
```jsx
147
-
// Component composition example
148
-
exportconstMyField= ({ source, ...props }) => {
149
-
constrecord=useRecordContext();
150
-
return (
151
-
<TextField
152
-
{...props} // Pass through all additional props
153
-
value={record?.[source]}
154
-
/>
155
-
);
156
-
};
157
-
```
158
-
159
-
### File Organization
160
-
- **Feature-based structure** within packages (not type-based)
161
-
- **Co-location** - Tests (`.spec.tsx`) and stories (`.stories.tsx`) next to components
162
-
- **Index exports** - Each directory has an index.ts exporting public API
163
-
- **Flat structure** within features - avoid unnecessary nesting
164
-
165
-
### Documentation
166
-
167
-
Every new feature or API change must be documented. The documentation consists of Markdown files located in the `/docs/` directory and built with Jekyll, one file per component or hook.
168
-
169
-
All documentation files must include:
170
-
171
-
- A brief description of the component or hook
172
-
- Usage examples
173
-
- List of props or parameters (required props first, then in alphabetical order)
174
-
- Detailed usage for each prop/parameter (in alphabetical order)
175
-
- Recipes and advanced usage examples if applicable
176
-
177
-
Headless hooks and components (the ones in `ra-core`) are also documented in the `/docs_headless/` directory.
178
-
179
-
### Pre-commit Hooks
180
-
181
-
- Automatic test execution for modified files
182
-
- Prettier formatting check
183
-
- ESLint validation
184
-
- TypeScript compilation
54
+
## Testing
185
55
56
+
All changes must include tests.
186
57
187
-
### Development Workflow
188
-
```bash
189
-
# Initial setup
190
-
make install # Install all dependencies
191
-
192
-
# After making changes
193
-
make build # Build packages (TypeScript compilation)
194
-
make test # run unit and e2e tests
195
-
196
-
# Before pushing changes
197
-
make lint # Check code quality
198
-
make prettier # Format code
199
-
```
58
+
- Stories: every component needs `*.stories.tsx` covering all props. Use FakeRest for mock data. Make data realistic — stories are used for screenshots and visual testing
59
+
- Unit/integration tests: `*.spec.tsx` files should reuse the component's stories as test cases. Assert on user-visible output (text, interactions), not implementation details or HTML attributes
60
+
- E2E (Cypress): kept minimal, targeting `examples/simple/`. Only for critical user paths
200
61
201
-
### Pull Request Process
62
+
##Documentation
202
63
203
-
1. **Target branch**: `next` for features, `master` for bug fixes or documentation changes
204
-
2. **Required checks**:
205
-
- All tests passing (`make test`)
206
-
- Linting clean (`make lint`)
207
-
- Prettier formatted (`make prettier`)
208
-
- TypeScript compiles (`yarn typecheck`)
64
+
Every new feature or API change must be documented.
209
65
210
-
3. **Commit Messages**: Clear, descriptive messages focusing on "why"
211
-
```
212
-
fix: Prevent duplicate API calls in useGetList hook
213
-
feat: Add support for custom row actions in Datagrid
214
-
docs: Clarify dataProvider response format
215
-
```
216
-
217
-
4. **Documentation**: Update relevant docs for API changes
218
-
5. **Title**: Start with a verb (Add / Fix / Update / Remove), prefix with `[Doc]` or `[TypeScript]` if the change only concerns doc or types.
219
-
220
-
### Common Make Commands
221
-
```bash
222
-
make # Show all available commands
223
-
make install # Install dependencies
224
-
make build # Build all packages (CJS+ESM)
225
-
make test # Run all tests
226
-
make lint # Check code quality
227
-
make prettier # Format code
228
-
make run-simple # Run simple example
229
-
make run-demo # Run demo application
230
-
```
66
+
-`/docs/` (Jekyll) — one Markdown file per component or hook. Each file must include: description, usage examples, props/parameters list (required first, then alphabetical), detailed usage per prop, and recipes if applicable
67
+
-`/docs_headless/` (Astro + Starlight) — documents headless hooks and components from `ra-core`
231
68
232
-
### Performance Considerations
69
+
##Pull Requests
233
70
234
-
- Use `React.memo()` for expensive components
235
-
- Leverage `useMemo()` and `useCallback()` appropriately
236
-
- Use `useEvent()` (an internal hook) for memoized event handlers
237
-
- Implement pagination for large datasets
238
-
- Use query caching via React Query
239
-
240
-
### Accessibility
241
-
242
-
- Follow WCAG guidelines
243
-
- Ensure keyboard navigation works
244
-
- Provide proper ARIA labels
245
-
- Test with screen readers
246
-
247
-
### Browser Support
248
-
- Modern browsers only (Chrome, Firefox, Safari, Edge)
249
-
- No IE11 support
250
-
- ES5 compilation target for compatibility
251
-
252
-
## Misc
253
-
254
-
- **Don't use `React.cloneElement()`** - it breaks composition
- **Don't add comments** when code is self-explanatory
257
-
- **Don't add features** achievable in a few lines with pure React
258
-
- **Don't skip tests** - they run automatically on commit
259
-
- **Don't force push** to main/master branches
260
-
261
-
## Testing Requirements
262
-
263
-
All developments must include tests to ensure code quality and prevent regressions.
264
-
265
-
### Storybook
266
-
267
-
- **Location**: Stories alongside components as `*.stories.tsx`
268
-
- **Coverage**: All components must have stories demonstrating usage for all props
269
-
- **Mocking**: Use jest mocks sparingly, prefer integration tests
270
-
- **Data**: Use mock data providers (e.g., FakeRest) for stories. Make realistic data scenarios as the stories are also used for screenshots and visual testing.
271
-
272
-
### Unit & Integration Testing (Jest)
273
-
274
-
- **Location**: Tests alongside source files as `*.spec.tsx`
275
-
- **Test Cases**: Reuse the component's stories as test cases
276
-
- **Assertions**: Use testing-library to render and assert on elements. Don't test implementation details or HTML attributes, use assertions based on user interactions and visible output.
277
-
- **Commands**:
278
-
```bash
279
-
make test-unit # Run all unit and functional tests
280
-
npx jest [pattern] # Run specific tests
71
+
- Target branch: `next` for features, `master` for bug fixes or documentation
72
+
- Title: start with a verb (Add / Fix / Update / Remove). Prefix with `[Doc]` or `[TypeScript]` if the change only concerns docs or types
73
+
- Commit messages: conventional commits focusing on "why"
281
74
```
282
-
283
-
### E2E Testing (Cypress)
284
-
285
-
Kept minimal to critical user paths due to maintenance overhead.
286
-
287
-
- **Location**: `cypress/` directory
288
-
- **Target**: Simple example app (`examples/simple/`)
289
-
- **Coverage**: Critical user paths and interactions
290
-
- **Commands**:
291
-
292
-
```bash
293
-
make test-e2e # Run inCI mode
294
-
# or for local testing withGUI:
295
-
make run-simple # Start test app with vite
296
-
make test-e2e-local # Run e2e tests withGUI
75
+
fix: Prevent duplicate API calls in useGetList hook
76
+
feat: Add support for custom row actions in Datagrid
* [Fix] Prevent stale nested field values when re-adding items in SimpleFormIterator ([#11201](https://github.com/marmelab/react-admin/pull/11201)) ([WiXSL](https://github.com/WiXSL))
7
+
* Fix `useCreate` fails to update the cache when `id` equals 0 ([#11199](https://github.com/marmelab/react-admin/pull/11199)) ([ThieryMichel](https://github.com/ThieryMichel))
* Bump path-to-regexp from 0.1.12 to 0.1.13 ([#11210](https://github.com/marmelab/react-admin/pull/11210)) ([dependabot[bot]](https://github.com/apps/dependabot))
12
+
* Bump handlebars from 4.7.7 to 4.7.9 ([#11206](https://github.com/marmelab/react-admin/pull/11206)) ([dependabot[bot]](https://github.com/apps/dependabot))
13
+
* Bump astro from 5.15.9 to 5.18.1 ([#11205](https://github.com/marmelab/react-admin/pull/11205)) ([dependabot[bot]](https://github.com/apps/dependabot))
14
+
* Bump picomatch from 2.3.1 to 2.3.2 ([#11203](https://github.com/marmelab/react-admin/pull/11203)) ([dependabot[bot]](https://github.com/apps/dependabot))
15
+
* Bump smol-toml from 1.5.2 to 1.6.1 ([#11202](https://github.com/marmelab/react-admin/pull/11202)) ([dependabot[bot]](https://github.com/apps/dependabot))
16
+
* Bump flatted from 3.3.3 to 3.4.2 ([#11197](https://github.com/marmelab/react-admin/pull/11197)) ([dependabot[bot]](https://github.com/apps/dependabot))
17
+
* Bump h3 from 1.15.8 to 1.15.9 ([#11196](https://github.com/marmelab/react-admin/pull/11196)) ([dependabot[bot]](https://github.com/apps/dependabot))
18
+
* Bump h3 from 1.15.5 to 1.15.8 ([#11194](https://github.com/marmelab/react-admin/pull/11194)) ([dependabot[bot]](https://github.com/apps/dependabot))
19
+
* Bump devalue from 5.6.3 to 5.6.4 ([#11189](https://github.com/marmelab/react-admin/pull/11189)) ([dependabot[bot]](https://github.com/apps/dependabot))
20
+
* Fix tar security alerts ([#11215](https://github.com/marmelab/react-admin/pull/11215)) ([WiXSL](https://github.com/WiXSL))
* Fix SavedQuery when `disableSyncWithLocation` is set ([#11173](https://github.com/marmelab/react-admin/pull/11173)) ([ThieryMichel](https://github.com/ThieryMichel))
`<ArrayField>` creates a [`ListContext`](./useListContext.md) with the field value, and renders its children components - usually iterator components like [`<DataTable>`](./DataTable.md) or [`<SingleFieldList>`](./SingleFieldList.md).
14
14
15
+
`<ArrayField>` is the Material UI export of the headless [`<ArrayFieldBase>`](https://marmelab.com/ra-core/arrayfieldbase/) component from `ra-core`.
16
+
15
17
## Usage
16
18
17
19
`<ArrayField>` is ideal for collections of objects, e.g. `tags` and `backlinks` in the following `post` object:
Copy file name to clipboardExpand all lines: docs/Translation.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -340,4 +340,14 @@ The following components take advantage of browser localization:
340
340
- [`<DateRangeInput>`](./DateRangeInput.md)
341
341
- [ `<NumberField>`](./NumberField.md)
342
342
- [`<NumberInput>`](./NumberInput.md)
343
-
- [`<TimeInput>`](./TimeInput.md)
343
+
- [`<TimeInput>`](./TimeInput.md)
344
+
345
+
## Agent Skill
346
+
347
+
React-admin provides a specialized agent skill to help you translate your application. Install it in your repository with the [`skills`](https://skills.sh/) command:
348
+
349
+
```bash
350
+
npx skills add marmelab/react-admin --skill i18n
351
+
```
352
+
353
+
This works with OpenCode, Claude Code, Codex, Cursor, and many more.
0 commit comments