swrobel
swrobel

Reputation: 4230

Mount react-admin under /admin

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.

Upvotes: 3

Views: 1371

Answers (4)

Aleksandr Taran
Aleksandr Taran

Reputation: 1

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">

Upvotes: 0

adamcee
adamcee

Reputation: 81

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.

Upvotes: 0

swrobel
swrobel

Reputation: 4230

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} />

Upvotes: 11

paws
paws

Reputation: 1311

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.

Upvotes: 2

Related Questions