3

I simply want all of my admin pages to be under /admin.

<Admin
  title="Admin"
  dashboard={Dashboard}
  dataProvider={restClient}
  history={history}
>
  <Resource
    name="users"
    list={UserList}
  />
</Admin>

My main page is at /admin but when I click Users in the sidebar, it changes the path to /users and not /admin/users.

I'm using react-admin 2.0.0.

swrobel
  • 4,053
  • 2
  • 33
  • 42

4 Answers4

11

The key is actually in the history prop passed to the Admin component:

import createHistory from 'history/createBrowserHistory';

const history = createHistory({ basename: '/admin' });

<Admin history={history} />
swrobel
  • 4,053
  • 2
  • 33
  • 42
2

react-router v4 expects a basename prop to arrange what you desire. More info here.

It's not clear that react-admin exposes a way for you to provide this, at least I'm not aware of one.

paws
  • 1,263
  • 15
  • 23
0

We had to use nginx and host two completely different apps to do this. It does not seem easy at all to integrate react-admin with another application already using react-router. The documentation provides some help, but the documentation also is often difficult to follow so I was very trepidatious of copying and pasting it's code to try and do this.

Ovverall I've been more frustrated with react-admin the longer I use it; I think there are some great things about the project but the documentation is not well-organized, there's no easy-to-read API reference, and there are a lot of leaky abstractions in that you really have to understand the material-ui, react-final-forms, and of course react-router packages to do anything even remotely 'outside the box' with react-admin.

Sorry to vent, but, my two cents is, split the app or use a different tool.

adamcee
  • 81
  • 1
  • 2
0

Not sure it is going to work for all versions. In my case, the solution with history has not worked. I've done the following approach:

<Admin basename="/admin">