Persistent variables and collections

Before, variables (and collections) were reset to their default value when the user changed page.

Now, they persist by default, meaning when you use a variable or collection on multiple pages, it will only be loaded once.

Your old variables will keep the previous behavior because we didn’t want to risk breaking the logic of your projects. However, if you want to change this setting, you can enable the option on each variable:

Save in local storage vs Preserve on navigation

So why did we make this change and add the "Preserve on navigation" option. What's the difference with "Save in local storage"?

When you save a variable in local storage, it is saved in the user's browser for as long as the user doesn't clear their browser's cache. This is useful if you need to save a user's preferences in between sessions but don't want to store the info in your database. For example, if you want to save the shopping cart of an anonymous user.

Variables that are preserved on navigation – i.e. when the user changes page while navigating inside the app – are cleared from the user's browser as soon as they navigate away from the app or if they refresh the page. This new setting means that you no longer have to save variables in local storage to ensure variables persist between pages.

This is important because it allow you a third behavior that is the most common in web apps. Previously you had the choice between no persist or hard persist (“Save in local storage”), but most use cases need a soft persist (“Preserve on navigation”).

For example, you want your search bar to be reset between visits but not during the navigation. During the navigation, you want your search bar to continue showing to the user what they searched for even if they are redirected to another page.

Start building for free

Sign up now, pay when you're ready to publish.