Custom session data only for client #363

Closed
opened 2026-03-13 07:43:24 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ttsirkia on GitHub (Dec 7, 2024).

Is your feature request related to a problem? Please describe.
A feature request or (maybe) a misunderstanding of the documentation

Describe the solution you'd like
There is currently a way to customize the session data for useSession and getSession. However, if I understood correctly, this will always affect both the server and client session data.

There are lots of different kind of scenarios that the session data contains some data which is not meant to be exposed to client. Therefore, it would be very useful to have a possibility to have two different shapes for the session data: one containing all the data and used in the server-side as well as one which can be publicly seen in the client-side.

Originally created by @ttsirkia on GitHub (Dec 7, 2024). **Is your feature request related to a problem? Please describe.** A feature request or (maybe) a misunderstanding of the documentation **Describe the solution you'd like** There is currently a way to customize the session data for `useSession` and `getSession`. However, if I understood correctly, this will always affect both the server and client session data. There are lots of different kind of scenarios that the session data contains some data which is not meant to be exposed to client. Therefore, it would be very useful to have a possibility to have two different shapes for the session data: one containing all the data and used in the server-side as well as one which can be publicly seen in the client-side.
Author
Owner

@moshetanzer commented on GitHub (Mar 23, 2025):

Hey,

You can always create a function to just get the data you need from db for server side.

I think that implementing this would confuse the average user. @Bekacru any thoughts?

@moshetanzer commented on GitHub (Mar 23, 2025): Hey, You can always create a function to just get the data you need from db for server side. I think that implementing this would confuse the average user. @Bekacru any thoughts?
Author
Owner

@Bekacru commented on GitHub (Mar 23, 2025):

Yea agreed. You can make a custom endpoint that you can call from the client.

@Bekacru commented on GitHub (Mar 23, 2025): Yea agreed. You can make a custom endpoint that you can call from the client.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#363