Questions tagged [react-admin]

A frontend Framework for building admin applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Material Design. Previously named admin-on-rest. Open sourced and maintained by marmelab.

Links

Features

  • Backend Agnostic: Connects to any API (REST or GraphQL, see the list of more than 45 adapters)

  • All The Building Blocks You Need: Provides hooks and components for authentication, routing, forms & validation, datagrid, search & filter, relationships, validation, roles & permissions, rich text editor, i18n, notifications, menus, theming, caching, etc.

  • High Quality: Accessibility, responsive, secure, fast, testable

  • Great Developer Experience: Complete documentation, IDE autocompletion, type safety, storybook, demo apps with source code, modular architecture, declarative API

  • Great User Experience: Optimistic rendering, filter-as-you-type, undo, preferences, saved queries

  • Complete Customization: Replace any component with your own

  • ☂️ Opt-In Types: Develop either in TypeScript or JavaScript

  • ‍‍‍ Powered by MUI, react-hook-form, react-router, react-query, TypeScript and a few more.

At a Glance

// in app.js
import * as React from "react";
import { render } from 'react-dom';
import { Admin, Resource } from 'react-admin';
import restProvider from 'ra-data-simple-rest';

import { PostList, PostEdit, PostCreate, PostIcon } from './posts';

render(
    <Admin dataProvider={restProvider('http://localhost:3000')}>
        <Resource name="posts" list={PostList} edit={PostEdit} create={PostCreate} icon={PostIcon} />
    </Admin>,
    document.getElementById('root')
);

The <Resource> component is a configuration component that allows to define sub components for each of the admin view: list, edit, and create. These components use MUI and custom components from react-admin:

// in posts.js
import * as React from "react";
import { List, Datagrid, Edit, Create, SimpleForm, DateField, TextField, EditButton, TextInput, DateInput, useRecordContext } from 'react-admin';
import BookIcon from '@mui/icons-material/Book';
export const PostIcon = BookIcon;

export const PostList = () => (
    <List>
        <Datagrid>
            <TextField source="id" />
            <TextField source="title" />
            <DateField source="published_at" />
            <TextField source="average_note" />
            <TextField source="views" />
            <EditButton />
        </Datagrid>
    </List>
);

const PostTitle = () => {
    const record = useRecordContext();
    return <span>Post {record ? `"${record.title}"` : ''}</span>;
};

export const PostEdit = () => (
    <Edit title={<PostTitle />}>
        <SimpleForm>
            <TextInput disabled source="id" />
            <TextInput source="title" />
            <TextInput source="teaser" options={{ multiline: true }} />
            <TextInput multiline source="body" />
            <DateInput label="Publication date" source="published_at" />
            <TextInput source="average_note" />
            <TextInput disabled label="Nb views" source="views" />
        </SimpleForm>
    </Edit>
);

export const PostCreate = () => (
    <Create title="Create a Post">
        <SimpleForm>
            <TextInput source="title" />
            <TextInput source="teaser" options={{ multiline: true }} />
            <TextInput multiline source="body" />
            <TextInput label="Publication date" source="published_at" />
            <TextInput source="average_note" />
        </SimpleForm>
    </Create>
);
1781 questions
47
votes
9 answers

Heroku server crashes with "JavaScript heap out of memory" when deploying 'react-admin' app

I am currently developing an admin panel using 'react-admin' which works well on my local, but as soon as I upload the app to Heroku, the build fails with the following error: "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed…
Vladimir_Grigore
  • 521
  • 1
  • 4
  • 8
20
votes
5 answers

React-admin Array input with array of strings/numbers

https://marmelab.com/react-admin/Inputs.html#arrayinput Examples cover cases where you have an array of objects: backlinks: [ { date: '2012-08-10T00:00:00.000Z', url: 'http://example.com/foo/bar.html', }, …
yBrodsky
  • 4,981
  • 3
  • 20
  • 31
19
votes
6 answers

Is it possible to have multiple dataProviders in react-admin?

If I have multiple distinct REST API back-ends (separate apps doing separate things), and I want a single UI (react-admin-based) app that is capable of doing CRUD to entities managed by these various back-ends, I'm curious if it's possible to wire…
Curt
  • 221
  • 2
  • 4
16
votes
1 answer

Force GET_ONE request when navigating to Show page

As I believe is common in many APIs, ours returns a subset of fields for a record when it is part of a List request, and more details when it is a single-record request to its Show endpoint. It seems that react-admin attempts to avoid doing a second…
swrobel
  • 4,053
  • 2
  • 33
  • 42
15
votes
4 answers

How to use Auth0 with react-admin?

I'm trying to implement authentication using Auth0 in a react-admin v3 app. I need to implement an authProvider that talks with Auth0. This sounds like something that should be available somewhere, but the closest I could find was…
Vitor Baptista
  • 2,016
  • 1
  • 23
  • 28
14
votes
3 answers

React Admin - Get current value in a form

I am having big troubles getting the "updated" value of a record in an edit form. I always get the initial record values, even though I have an input linked to the right record source, which should update it. Is there an alternative way to get the…
Nicolas Kern
  • 279
  • 2
  • 3
  • 11
13
votes
2 answers

How to organise a Show layout in React Admin using a Material UI Grid

I've created a number of Show views in a new React-Admin project. Rather than have the fields just form a single column I would like to use Material UI's Grid component to arrange them into a more efficient and helpful layout. Unfortunately this…
Best Mamgu Ever
  • 303
  • 2
  • 10
12
votes
1 answer

react-admin with next js

I am creating an app with React using Nextjs. I'd like to really use react-admin for my BO. I tried test example and with react it works perfectly. Unfortunately, while I am trying to include some code to next js - it doesn't work. I created…
ChilTest
  • 461
  • 5
  • 18
12
votes
2 answers

How do I import react-admin in a React Typescript appplication?

I'm trying to set up a react-admin app in typescript and I can't quite figure out how to import react-admin. It gives me the (simple) error saying "Could not find a declaration file for module 'react-admin'.…
Mike
  • 627
  • 1
  • 7
  • 21
12
votes
4 answers

How can I create a custom page with #react-admin without the menu sidebar like login page?

I am using react-admin previously admin-on-rest. I want to create a custom page that doesn't show the Menu sidebar, like Login page. I will use this page reset user's password. How can I do that?
thecassion
  • 506
  • 1
  • 7
  • 19
12
votes
4 answers

how can I show customized error messaged from server side validation in React Admin package?

Is there any way to perform server side form validation using https://github.com/marmelab/react-admin package? Here's the code for AdminCreate Component. It sends create request to api. Api returns validation error with status code 422 or status…
Gago Muradyan
  • 195
  • 3
  • 11
11
votes
1 answer

Fetch data only the first time go to a Tab in a TabbedForm

I have a tabbed form that the second tab will retrieve a list from the backend, similar to the react-admin official demo (e.g. post has many comments). The problem is when I switch the tab, there is always a backend call for the second tab which is…
sunfly
  • 191
  • 6
11
votes
2 answers

In react-admin get access to redux store

My question is related to react-admin repo. I want to dispatch an action, outside of scope of a component, in order to do that, I've read that I need to get access to the actual redux store itself, and dispatch on in directly, so I know that the…
Developerium
  • 7,155
  • 5
  • 36
  • 56
10
votes
7 answers

Yarn Start Command failed with exit code 1

I create react app with create-react-app and install react-admin . when I want to start development server with yarn start throw an error unhand-led 'error' event and say Command failed with exit code 1 I search a lot but nothing helped. See the…
10
votes
2 answers

Show API error in notification

I'm missing something basic in the docs. When I get an API validation error, I'm returning a status code and message. It appears that React-Admin is translating the status code to a generic HTTP error code. My error response. {"error": …
Curtis Olson
  • 315
  • 3
  • 12
1
2 3
99 100