How can I navigate to another page based on tab selection

I have a page with two tabs and the visibility is set based on the access token from an API call. One of the tabs contains list of data and other one is for prompting the user to go to login page using a button . I want to navigate to login page if the access token is null or expired without a button click . Is there any solution for this .

Hey @Ginjo, you can control tab navigation using JavaScript. This thread helps you with how you can do it:

Alternatively, the same problem is discussed in this video, sending you the link with the timestamp:

Let us know if you need any help :slight_smile:

Hi, @viharkurama I have mentioned that ‘without button click’ in my question. I want to navigate to another page based on the default tab set up ( on page load itself , without any button click ) .

Hey @Ginjo, you can do this by writing a condition on the Default Tab property by storing the Token on appsmith local store.

Say Tab 1 is the login page, and Tab 2 is a secure page.

You can store the Token in a ‘token’ variable after the API call using the storeValue function.

{{storeValue("token", "secrettoken")}}

On the default tab property, you can use conditions like:

{{ ? "Tab 2" : "Tab 1"}}

I hope this is what you’re looking for.

@viharkurama thank you for your support . I will try it and let you know

@viharkurama Sorry for late reply . It is working fine with the above mentioned solutions .

1 Like