Retool doesn't return to the default page when reloading

Hi,

I’m having an issue with reloading the app. When I press F5 or Ctrl+F5, the app stays on the screen I’m on and doesn’t go to the default screen.

I have tried adding several scripts in Preloaded JS, but for example, “utils” is not available. Does anyone know how to solve this issue?

Thank you in advance.

1 Like

@Albertoerto

If you always want the app to open on the default page:

:backhand_index_pointing_right: Open the app using this format:

https://yourcompany.retool.com/apps/Your_App_Name

or

you must use “window.retool” instead of “utils”, because utilities like utils.navigateTo() are NOT available in Preloaded JS.

Use this code in Preloaded JS:

window.onload = () => {
  // Change 'Home' to the name of your default page
  window.retool.navigateToApp('Your_App_Name', {
    pageName: 'Home'
  });
};

:fire: Notes:

  • Replace "Your_App_Name" with your exact app name.

  • Replace "Home" with your default page name.

  • This runs only when app first loads, including F5 / Ctrl+F5.

HI @Anuragsinh,

I tried what you suggested, but the same thing keeps happening. When I'm on another screen and press F5 or Ctrl+F5, it stays on the screen I'm on and doesn't return to the main screen.

I don't understand why this is happening, but none of the options I try work. Could it be a bug?

Thank you for your attention.

Hey @Albertoerto, thanks for reporting this! Have you tried setting it up directly in the Pages tab like this?

If you can share a quick screenshot of what you currently have in the Pages tab, that would help me see if anything looks off. Thanks!

Hello! Yes, I already have the page set as my home page, but when I press F5, it doesn't return to the previous page, it reloads the screen I was on before pressing F5.

Thank you for your attention.

Hey @Albertoerto, sorry I totally missed this in your first post, I’m on a Mac myself haha. On Windows, F5 just refreshes the current page, so it won’t navigate to another page or reset anything, which is why you’re not seeing it change pages.

Your default page should load automatically when you first land on the app URL. Is that what you are seeing when you go to your site?