How does preserve on nav + fetch automatically work together?

Hey guys! Wondering if someone could explain to me how it works when a collection has both “Preserve on Navigation” and “Fetch Automatically”.

If both are ticked, when exactly is that collection fetched automatically? Is it each time the user logs into the platform? And if they closed their browser for example and opened again and were still logged in, would that collection be fetched again?

Hi, the collection will be fetched automatically once your user visit a page using it.

Preserve On Navigation is only about changing page inside your application, so the collection is not fetch again every page change. If your user leave the app and come back the collection will be fetched again.

1 Like

Thank you Alexis! And when you say it’ll be fetched by every page using it, do you mean pages that have a trigger workflow that fetches the collection on page load?

Or just any page that has a collection list on it for example that utilizes that collection?

The second one, we detect automatically if your page need the collection (if anything is bound to the collection) and fetch it if the option is toggled ON :slight_smile:

Okay thank you! Do you have any recommendation on specific types of collections that should be NOT set to preserve on navigation?

My project structure is very nested similar to a project management tool in the form of projects (which click into) → pages (which click into) → Tasks, Files, Etc

Would it be good practice to make very single collection type preserve on nav and fetch automatically based on that structure?

Preserve on navigation + fetch automatically allow you to avoid overfetching your API.

Its useful if the data are not changing during the navigation, but you may want to refresh your collection between every page change. It depends completely of your usage and flow, and the update frequency you want.

Preserve has two usage =>

  • Create a light cache
  • Avoid fetching again if you navigate between two page that require the same data

I’ve no specific recommandation in mind except you have to be aware if you toggle both automatic fetch and preserve on navigation and never set a fetch collection action in a workflow, your users will be stuck with the first data they loaded and will need to reload the app to refresh the data. So you may need to add some refresh buttons somewhere for example.

Preserve on navigation is very cool if you only need to load your collection once on App load with a workflow or after a specific action like an authentication, it ensure the collection will still persist during the navigation, and if the user refresh the app it will go through the on app load again so it will reload the collection again and persist it.

Hi @Alexis. Love how active you are on the forum. It’s super super helpful.

In a related vein, any update on real-time data updates from Xano? Not sure if you are dependent on Xano making updates for the front end to support this but would be curious your thoughts and if the team plans to work on this in the next few months.

Thanks!

Hi @Jack, thanks for your message!

Native realtime feature has not been released by Xano yet, but once they did we will probably put it on top priority to implement it. We are currently working on improving realtime on supabase, what we are doing will also help us developing realtime faster with Xano once they are ready. :slight_smile: