# Persisting log in state: If logged in, I want users to jump straight to the post-login page (Xano x WeWeb)

**URL:** <https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901>\
**Category:** How do I?\
**Tags:** xano\
**Created:** [October 14, 2023, 6:30am UTC](https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901 "2023-10-14T06:30:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonnykane](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@sonnykane](https://community.weweb.io/u/sonnykane)\
**Post date:** [October 14, 2023, 6:30am UTC](https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901/1 "2023-10-14T06:30:39Z")

</div>

Hi. I just finished developing a webapp on WeWeb and want to deploy it on a subdomain [app.mysite.com](http://app.mysite.com).

[app.mysite.com](http://app.mysite.com) also is the login page.

On successful auth, user is redirected to [app.mysite.com/home](http://app.mysite.com/home)

Let’s say the user is logged in and hasn’t logged out.

They just start typing in the address bar “[app.mysite.com](http://app.mysite.com)”. Though they’re logged in, they’re taken to the [app.mysite.com](http://app.mysite.com) page, which shows the login screen. Please note that I can see their auth state in Xano is TRUE at this point, and am able to redirect them using a “On page load (before fetching collections)” workflow where I check their Xano auth state and redirect them to /home if logged in. But the user sees the [app.mysite.com](http://app.mysite.com) (login page) briefly before the redirect happens - which is a subpar UX. Could someone help me achieve this - as soon as the URL is typed in, check for user’s auth state and redirect them directly to the /home page if they’re logged in?

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [October 15, 2023, 10:49am UTC](https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901/2 "2023-10-15T10:49:45Z")

</div>

There are a few techniques, but these two are most common:

1. Make the login page a different page. Make the home page your “dashboard”. Have people come to the home page, and have that page bounce them to the login page when they are not logged in as part of the authorization check.

2. Make the login page the home page, but on page load, run an authentication check and redirect the user to the main “dashboard” page or what have you if they are logged in.

In truth, both of these are about the same underlying a mechanic: a check on page load that asks, “do you belong here”. They just handle it in opposite ways.

---

<div class="post-metadata">

**Author:** ![sonnykane](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@sonnykane](https://community.weweb.io/u/sonnykane)\
**Post date:** [October 15, 2023, 5:42pm UTC](https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901/3 "2023-10-15T17:42:43Z")

</div>

Thanks @raydeck for the response.

> [@raydeck](#):
>
> Make the login page the home page, but on page load, run an authentication check and redirect the user to the main “dashboard” page or what have you if they are logged in.

I think what you’ve suggested with the second approach is what I’ve already done? However, WeWeb shows the logged-in user the login page before redirecting to the /home page, which I feel is suboptimal UX. Attaching a screenshot to share how I’ve set this up (so someone can point if I’ve done it wrong).

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/a/a6bf9518705dd8e156faf3f0e5634db54150ea37.png)

I thought the “Page loader” (in the above screenshot) being shown before the auth check was an issue, so I removed. But that didn’t solve it either. I also tried doing this workflow “On page load” instead of “On page load before fetching collections”. No luck with that one.

Lastly, I also tried the first approach you’ve suggested. It resulted in the same issue. Home page is shown for a flash second, before redirecting the user to login page.

Any insights on what’s going on here please?

Thanks again!

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [October 16, 2023, 11:03am UTC](https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901/4 "2023-10-16T11:03:11Z")

</div>

Basically what you have is a sequencing problem. You are 1) loading the page 2) making an authentication check (via auth/me) and 3) redirecting based on the result. Because (2) takes time, you see the flash.

This experience is very common in authenticated apps, because there is a period of time in which you are on the “wrong page.” Many apps live with this experience.

However, it’s not inevitable. You can put a page loader div (like a curtain that has your brand logo or what have you, 100vw height and width, position fixed) over your page that displays by default and is removed if this is the page you’re supposed to be on. So if you start from the login screen, the login screen just shows your brand glowing or something and then sends you where you should go. If you are supposed to be on that page, just hide the div. This is logically like the page loader but more under your control so that you can dial in the experience you want for the users in the 500ms between when they open the page and when they get sent to the right place.

Another thing you can do is introduce a check for whether the xano auth key is present in cookies. That would let your page determine faster whether it needs to change position. That might require a little JS, but would make the time showing the “wrong” page go down by a lot in most circumstances.

Like a lot of UX questions, this is about feel and your judgment. Try some approaches to dial in the experience that is right for your customers!

---

<div class="post-metadata">

**Author:** ![sonnykane](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@sonnykane](https://community.weweb.io/u/sonnykane)\
**Post date:** [October 17, 2023, 8:37pm UTC](https://community.weweb.io/t/persisting-log-in-state-if-logged-in-i-want-users-to-jump-straight-to-the-post-login-page-xano-x-weweb/4901/5 "2023-10-17T20:37:45Z")

</div>

> [@raydeck](#):
>
> However, it’s not inevitable. You can put a page loader div (like a curtain that has your brand logo or what have you, 100vw height and width, position fixed) over your page that displays by default and is removed if this is the page you’re supposed to be on. So if you start from the login screen, the login screen just shows your brand glowing or something and then sends you where you should go. If you are supposed to be on that page, just hide the div. This is logically like the page loader but more under your control so that you can dial in the experience you want for the users in the 500ms between when they open the page and when they get sent to the right place.

That made a lot of sense, thanks for the very clear explanation @raydeck! Appreciate it! 🙌
