• silas@programming.devOPM
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    11 months ago

    Well, I usually fetch and return user data from a top-level +layout.js or +layout.server.js. Then my user data is always available in every layout or page through the data prop (and types are all handle automatically for this too).

    I then invalidate and re-fetch that data using invalidate(), invalidateAll(), and depends() if the user data becomes stale.

    Any state/data from the user that needs to stay server-side (like tokens) I keep in event.locals which is available in all .server.js files