Deploying NextJS + ReactJS + Auth0 on Vercel
Unanswered
Tramp ant posted this in #help-forum
Tramp antOP
Hello,
Noob starter here with NextJS. I am trying to use this starter template: https://github.com/twbs/examples/tree/main/react-nextjs/ and add Auth0. However, I have a few doubts that I cannot seem to clear. In my mind, using Auth0 in client side to protect a whole app (app.example.com) is not feasible, but using server side rendering would play nicely in terms of security. To be completely honest I don't know how to make this example project fully SSR/Edge; I have tried to follow a few tutorials but they are inconsistent. For example, I tried to deploy this on CF Pages by following this: https://github.com/cloudflare/next-on-pages/blob/main/packages/next-on-pages/docs/examples.md but it does not build. Then I read about Vercel's Edge stuff but again it's not clear for me how to use it, but it's clear that Vercel is more suitable for NextJS than CF. So I guess my 2 questions are:
1. How can I make this starter template use SSR/Edge on Vercel?
2. One I achieve this, how can I check/ensure that the relevant code is running on the server only?
Many thanks!
Noob starter here with NextJS. I am trying to use this starter template: https://github.com/twbs/examples/tree/main/react-nextjs/ and add Auth0. However, I have a few doubts that I cannot seem to clear. In my mind, using Auth0 in client side to protect a whole app (app.example.com) is not feasible, but using server side rendering would play nicely in terms of security. To be completely honest I don't know how to make this example project fully SSR/Edge; I have tried to follow a few tutorials but they are inconsistent. For example, I tried to deploy this on CF Pages by following this: https://github.com/cloudflare/next-on-pages/blob/main/packages/next-on-pages/docs/examples.md but it does not build. Then I read about Vercel's Edge stuff but again it's not clear for me how to use it, but it's clear that Vercel is more suitable for NextJS than CF. So I guess my 2 questions are:
1. How can I make this starter template use SSR/Edge on Vercel?
2. One I achieve this, how can I check/ensure that the relevant code is running on the server only?
Many thanks!
6 Replies
Tramp antOP
@Arinji Thank you, but it's not 100% clear to me what I need to edit in the starter template mentioned, if that makes sense? I just began learning about NextJS and ReactJS.
Tramp antOP
I had a bit more reading around, but it's still not clear to me how I can adapt the above example to protect it via server side code and Auth0 😦
However... I checked out a few examples and apparently the Auth0 examples on the vercel site are all SPA (client side auth), which is not good for me.
Ideally, I would want to achieve something like chatgpt/openai did by protecting their whole app (like this: https://chat.openai.com/auth/login)
But since I cannot get anywhere at the moment... I would even settle for this example: https://nextjs-postgres-auth.vercel.app/ (considering I am right after checking the code that the auth is done server side - no client side exposed and that I can protect the whole app with it)