# OktaWidget with ReactJs code - Redirection Issue

**URL:** <https://devforum.okta.com/t/oktawidget-with-reactjs-code-redirection-issue/15197>\
**Category:** Questions\
**Created:** [July 20, 2021, 3:09pm UTC](https://devforum.okta.com/t/oktawidget-with-reactjs-code-redirection-issue/15197 "2021-07-20T15:09:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaviMarpally](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@RaviMarpally](https://devforum.okta.com/u/RaviMarpally)\
**Post date:** [July 20, 2021, 3:09pm UTC](https://devforum.okta.com/t/oktawidget-with-reactjs-code-redirection-issue/15197/1 "2021-07-20T15:09:29Z")

</div>

I am trying to use the Okta Widget to authenticate and redirect the User to a new Website from ReactJs code but it stops after the Authentication and doesn’t proceed with redirection.

Followed steps as mentioned in Okta guide URL:  
[https://developer.okta.com/code/javascript/okta\_sign-in\_widget/](https://developer.okta.com/code/javascript/okta_sign-in_widget/)

However I am able to achieve the same functionality following the steps from below url but it did not use the Okta Widget.  
[https://developer.okta.com/code/react/okta\_react/](https://developer.okta.com/code/react/okta_react/)

Error: Tokens values are getting as undefined in “OnSuccess” function  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/8/80844e522c5d274b22c4c8589c1e8ca28fb3c542.png)

---

<div class="post-metadata">

**Author:** ![okra-okta](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/okra-okta/32/2838_2.png) [@okra-okta](https://devforum.okta.com/u/okra-okta)\
**Post date:** [July 20, 2021, 4:19pm UTC](https://devforum.okta.com/t/oktawidget-with-reactjs-code-redirection-issue/15197/2 "2021-07-20T16:19:17Z")

</div>

You might want to check out this sample app which uses a self-hosted widget with React.

> **[okta/samples-js-react](https://github.com/okta/samples-js-react/tree/master/custom-login)**
>
> master/custom-login

---

<div class="post-metadata">

**Author:** ![RaviMarpally](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@RaviMarpally](https://devforum.okta.com/u/RaviMarpally)\
**Post date:** [July 21, 2021, 5:20pm UTC](https://devforum.okta.com/t/oktawidget-with-reactjs-code-redirection-issue/15197/3 "2021-07-21T17:20:04Z")

</div>

This is not working in my scenario. I am able to open the Okta Widget and Login but the redirection part seems to failing.  
In the below code ‘res.tokens’ value is not available and my response obj consists of ‘session and user’ details.

widget.renderEl(  
{ el: widgetRef.current },  
(res) =\> {  
console.log(res);  
oktaAuth.handleLoginRedirect(res.tokens);  
},  
(err) =\> {  
throw err;  
}  
);

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 10, 2024, 12:47am UTC](https://devforum.okta.com/t/oktawidget-with-reactjs-code-redirection-issue/15197/4 "2024-02-10T00:47:02Z")

</div>


