okta / okta-react

Okta OIDC SDK for React
https://github.com/okta/okta-react
Other
114 stars 78 forks source link

Example usage with nextjs #52

Open gregkonush opened 3 years ago

gregkonush commented 3 years ago

it seems like this library gives opinions about the routing solutions that exist in the react ecosystem. However, there are some frameworks like nextjs that have their own file-based router implementation. How would one go about implementing implicit auth flow without react-router or reach-router? Oh, also given the fact I don't want to use the next-auth.js library or other server-side implementations for oidc that are available. Auth0 provides library SDK for their oidc integration

shuowu commented 3 years ago

@gregkonush Thanks for submitting the request!

I agree we should add this, but not sure when we can get to it, we'd have to spend time looking at the right way to do it.

Internal Ref: OKTA-348966

samantha-wong commented 3 years ago

+1 on this issue, I've been stuck on v3 since forever... I just tried upgrading to the latest version again and can't get pass server error TypeError: Cannot read property 'getAuthState' of undefined 😔

aarongranick-okta commented 3 years ago

@samantha-wong you mentioned a "server error". Are you trying to use okta-react from the server-side? If so, this error would be expected as this SDK does not currently support NodeJS

samantha-wong commented 3 years ago

@aarongranick-okta yes we are, we're still using v3 of otka-react with okta-auth-js in our nextjs project. Do you have a suggestion on how we can move off this? Our login and sign pages are custom and we don't want to use okta's login widget. Any help appreciated 🙏

aarongranick-okta commented 3 years ago

@samantha-wong okta-react is designed to work client-side. okta-auth-js has limited functionality server-side. Both of these SDK's are open-source, however so you can take whatever pieces are useful.

If you'd like to use react on the server-side, I would recommend against using our okta-react library at this time.

ashinga48 commented 2 years ago

Hey guys, Seeing this still exists. Officially recommended next-auth only works with server.

We have deployed a package in npm @deeprecognition/okta-react-nextjs-spa to make it work with NextJS SPA static export https://www.npmjs.com/package/@deeprecognition/okta-react-nextjs-spa

Feel free to comment on any issues.

restcristian commented 2 years ago

Hi, I am trying to implement Okta login into a NextJS app. However, after using next-auth, it forwards me to the Okta login page. Is there a way to actually make it use my custom login page, and use the credentials obtained from it?

HugoP27 commented 2 years ago

Hi, I am trying to implement Okta login into a NextJS app. However, after using next-auth, it forwards me to the Okta login page. Is there a way to actually make it use my custom login page, and use the credentials obtained from it?

Hi @restcristian, were you able to host your own login page? I'm also stuck here

restcristian commented 2 years ago

Hi, I am trying to implement Okta login into a NextJS app. However, after using next-auth, it forwards me to the Okta login page. Is there a way to actually make it use my custom login page, and use the credentials obtained from it?

Hi @restcristian, were you able to host your own login page? I'm also stuck here

Hi @HugoP27 I ended up creating my login page myself as if it was SPA.