SolidJSS
SolidJS13mo ago
1 reply
hannus

Efficiently Managing Supabase Sessions and Context Sharing in SolidStart

I am developing an application using Supabase and SolidStart, and I’ve encountered some challenges related to session management and sharing a Supabase instance.

My Scenario
1. Session management after user login:
• After a user logs in, Supabase returns sessionData (including access tokens, etc.).
• I plan to use h3’s session to store this sessionData in the user’s cookies.

2. Handling subsequent requests:
• For each user request, I read the sessionData from the cookie, set it as Supabase’s session, and then use Supabase.
• However, setting the Supabase session on every request introduces overhead and feels redundant.

3. Optimization goal:
• I want to share a configured Supabase instance within the server lifecycle to avoid resetting it repeatedly and only update the session when necessary.
• I am considering using Context to achieve this shared instance.

My Questions
1. Can Context only be created on the client-side?
2. Is it possible to share Context between the client and the server?
3. Can Router use Context, enabling the preload attribute to leverage the shared Supabase instance for data fetching?

Any insights or suggestions would be greatly appreciated!:start: 🎉
Was this page helpful?