New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Doc] Add Next.js integration tutorial #7879
Conversation
const url = `${process.env.SUPABASE_URL}/rest/v1/${requestUrl}`; | ||
const options = { | ||
method: req.method, | ||
headers: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I realized in my remix example is that you also need to forward all the original request headers and override only those needed. Otherwise, some mutations do not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ones? In my tests, editions and deletions work fine.
Note: I did manually copy the prefer
header to allow getOne to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember right now but I ended up merging all the original headers and overriding the authentication ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll fix the example when and if needed
## Rendering React-Admin In A Sub Route | ||
|
||
In many cases, the admin is only a part of the application. For instance, you may want to render the admin in a subpath, e.g. `/admin`. | ||
|
||
Next.js makes it trivial: create a `pages/admin.tsx` file with the same content as in the previous section: | ||
|
||
```jsx | ||
// in pages/admin.tsx | ||
import type { NextPage } from "next"; | ||
import dynamic from "next/dynamic"; | ||
|
||
const App = dynamic(() => import("../src/admin/App"), { ssr: false }); | ||
|
||
const Admin: NextPage = () => { | ||
return <App />; | ||
}; | ||
|
||
export default Admin; | ||
``` | ||
|
||
Now the admin renders at `http://localhost:3000/admin`, and you can use the Next.js routing system to add more pages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to add a basename
prop to your Admin in this case? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because react-admin uses a HashRouter and Nextjs uses another router.
Based on https://marmelab.com/blog/2022/02/02/bootstrap-your-react-admin-project-with-nextjs.html
I could also add the authentication part, but it's for another PR.
No direct link from the sidebar yet, I'll wait until we have more integrations to make it public.