pass session via `<Outlet />`

Is it possible to pass session to outlet like this? It doesn't seem to work. I'm using solid-start alpha btw
export const { routeData, Page } = Sessionize(() => {
const session = useRouteData<typeof routeData>();
return (
<Show when={session()} keyed>
{s => <Outlet {...s} />}
</Show>
);
});

export default Page;
export const { routeData, Page } = Sessionize(() => {
const session = useRouteData<typeof routeData>();
return (
<Show when={session()} keyed>
{s => <Outlet {...s} />}
</Show>
);
});

export default Page;
3 Replies
Zanoryt
Zanoryt17mo ago
Have you thought about putting the session inside a Context? Then you can access that context (assuming you wrap the Context Provider in the main app outside of the Outlet area) from anything.
Trader101
Trader101OP17mo ago
route data is better because I believe when you update the session, it immediately reflects the changes on the page. Also tbh it's hard to maintain that context because you would need to know when oauth session ends so you query at an interval the api route and I think it's pretty ugly to make things work this way and solid-start indeed doesn't accept any params on outlet
Zanoryt
Zanoryt17mo ago
This is where you would consider createEffect() to watch for changes to the session, update the related store in the context, and anything underneath (in the tree) will benefit from any changes to the store.
Want results from more Discord servers?
Add your server