Christiano
02/15/2026, 10:52 PMlocalStorage.
Then, in my AdminHomePage I get the token from the localStorage, parse the token and check if it is expired or not.
Should the token not exist, or be expired, the check then automatically navigates to the login/home page. If it does exist, it should stay on the page.
However, the check somehow causes a flicker in the pages. Even though the check is still happening, the application already navigates to the Home/Login page, but then in a split second the check completes and shows the correct page (the admin panel)
@Page
@Composable
fun HomePage() {
isUserLoggedIn {
HomeScreen()
}
}
@Composable
fun HomeScreen() {
AdminPageLayout {
AddButton()
HomeContent()
}
}
The isUserLoggedIn function looks like this
@Composable
fun isUserLoggedIn(content: @Composable () -> Unit) {
val context = rememberPageContext()
val tokens = remember { window.localStorage.getItem("tokens") }
var tokensAreValid by remember { mutableStateOf(false) }
LaunchedEffect(key1 = Unit) {
tokensAreValid = if (!tokens.isNullOrEmpty()) TokenManager.areTokensStillValid(tokens) else false
if (!tokensAreValid) {
context.router.navigateTo(Navigation.Screen.Home.route)
}
}
if (tokensAreValid) {
content()
} else {
println("Loading...")
}
}
This only happens in an exported project, as long as I'm running the actual debug/develop mode this is not happening.
I'm afraid that it is not clear what I'm talking about, so if you need more information, don't hesitate to ask.
As far as I know, the localStorage is the culprit, if I remove that line and just hardcode a check, all works as intended... anyone ever had this issue?S.
02/15/2026, 11:15 PMNavigation.Screen.Home.route the "login" page or is that the same as @Page fun HomePage() ?
Is "Loading..." being printed before redirecting?
btw access tokens shouldn't really be stored in localstorageLetter
02/15/2026, 11:33 PMif (! AppGlobals.isExporting), which in your case should probably be the token checking logic. This will make the redirect not happen during export, preventing the flash.S.
02/15/2026, 11:39 PMChristiano
02/16/2026, 8:15 PMS.
02/16/2026, 9:46 PMLetter
02/16/2026, 11:11 PMChristiano
02/17/2026, 8:47 PM