Hello everyone,
I’m looking for some advice on the best way to trigger a workflow in my app.
I currently call a Postgres function through Supabase to get the user’s latest course and the current lesson they’re on. Once I have this data, I update two variables: course and lesson. These variables are then used as filters to fetch collections that depend on the user and their current course.
Originally, I was running this workflow on page load, but I realized that’s not ideal. I only want to fetch this information once, not every time the user navigates to a new page. The variables persist across navigation, so repeating the workflow is unnecessary. I also need these variables to be available across the entire app, not just on specific pages.
I considered using “on app load”, but that fires before the user is authenticated, so the workflow runs too early. Triggering it when the user logs in could work, but what happens if the user is already logged in when the app loads?
So my questions are:
-
What’s the recommended place to initialize this workflow?
-
How should I handle cases where the user is already authenticated when the app starts?
-
How long do Weweb variables persist in this context?
Any guidance or best practices would be greatly appreciated!
Mélanie