# Need a way to load application on window load without loop due to redirect after login with spa

**URL:** <https://community.auth0.com/t/need-a-way-to-load-application-on-window-load-without-loop-due-to-redirect-after-login-with-spa/6471>\
**Category:** Get Help\
**Tags:** spa, redirect, loop\
**Created:** [May 4, 2017, 6:48am UTC](https://community.auth0.com/t/need-a-way-to-load-application-on-window-load-without-loop-due-to-redirect-after-login-with-spa/6471 "2017-05-04T06:48:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tavon.macon-ellis](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tavon.macon-ellis](https://community.auth0.com/u/tavon.macon-ellis)\
**Post date:** [May 4, 2017, 6:48am UTC](https://community.auth0.com/t/need-a-way-to-load-application-on-window-load-without-loop-due-to-redirect-after-login-with-spa/6471/1 "2017-05-04T06:48:52Z")

</div>

Is this accomplished by having a state parameter? I don’t understand the logic. Could you assist us with a short snippet to try with our lock? we need to login and stay on page if successful.

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [May 4, 2017, 1:49pm UTC](https://community.auth0.com/t/need-a-way-to-load-application-on-window-load-without-loop-due-to-redirect-after-login-with-spa/6471/2 "2017-05-04T13:49:16Z")

</div>

I don’t see why there would be a loop. You should be listening for the `lock.on("authenticated",...)` event in your application to handle the response from Auth0 and load your application as required.

> **[Lock v11 for Web](https://auth0.com/docs/libraries/lock)**
>
> A widget that provides a frictionless login and signup experience for your web apps.

---

<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:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/need-a-way-to-load-application-on-window-load-without-loop-due-to-redirect-after-login-with-spa/6471/3 "2018-03-02T05:53:40Z")

</div>


