# How to handle state parameters to redirect

**URL:** <https://community.auth0.com/t/how-to-handle-state-parameters-to-redirect/118617>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [October 16, 2023, 11:54am UTC](https://community.auth0.com/t/how-to-handle-state-parameters-to-redirect/118617 "2023-10-16T11:54:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian3](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sebastian3/32/46707_2.png) [@sebastian3](https://community.auth0.com/u/sebastian3)\
**Post date:** [October 16, 2023, 11:54am UTC](https://community.auth0.com/t/how-to-handle-state-parameters-to-redirect/118617/1 "2023-10-16T11:54:25Z")

</div>

Hey,

This is a followup to this [topic regarding a redirect after login](https://community.auth0.com/t/how-to-redirect-users-to-same-page-after-log-in/68777) and more specifically about redirecting the user to a URL he was trying to access before logging in.

I checked the documentation about [redirecting users with state parameters](https://auth0.com/docs/secure/attack-protection/state-parameters#redirect-users) but it’s not entirely clear where to do that in a self-hosted auth0 implementation. Could anyone provide more technical details on where and when the state parameter can be accessed?

Thanks!

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [October 18, 2023, 12:40pm UTC](https://community.auth0.com/t/how-to-handle-state-parameters-to-redirect/118617/2 "2023-10-18T12:40:26Z")

</div>

Hey there @sebastian3 !

Looking at the Auth0’s Authentication API:

- The [redirect\_uri](https://auth0.com/docs/api/authentication#database-ad-ldap-passive-) query parameter of the /authorize request takes the value of the URL you intend the user back to once authenticated.

This [topic](https://community.auth0.com/t/auth0-react-spa-onredirectcallback-redirection-solution/42013) describes the implementation for the [React app](https://developer.auth0.com/resources/guides/spa/react/basic-authentication?_gl=1*mo87p7*_gcl_au*MTc2NDM5MjAxMi4xNjkzMzc3NDYz*rollup_ga*Njg5ODg1MDA4LjE2ODU1NDYzMTA.*rollup_ga_F1G3E656YZ*MTY5NzYyMzY2Ny4yODkuMS4xNjk3NjI1MDM0LjYwLjAuMA..*_ga*Njg5ODg1MDA4LjE2ODU1NDYzMTA.*_ga_QKMSDV5369*MTY5NzYyMjU0Ny4yNTcuMS4xNjk3NjI1MDM5LjU1LjAuMA..&_ga=2.254205451.2038263865.1697448152-689885008.1685546310#configure-a-react-authentication-provider) but looking analogically and taking away SDKs, in your app, you would define the user’s current [window location](https://developer.mozilla.org/en-US/docs/Web/API/Location) (current URL) and use the value it translates to for the redirect\_uri.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 8, 2023, 10:30am UTC](https://community.auth0.com/t/how-to-handle-state-parameters-to-redirect/118617/4 "2023-11-08T10:30:29Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
