[GH-ISSUE #7] Use localStorage? #8086

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

Originally created by @arthur-fontaine on GitHub (Sep 28, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7

The documentation mentions that better-auth uses cookies to store the session.

I never tried, but I think that React Native can't handle server set cookies, and I didn't see anything in the documentation that tells how to change how sessions are stored.

So my question is, is there a way to use another storage than cookies?

By reading your code, I think it is only feasible with plugins but not with an option. I guess that if we use plugins, we lose a bit of the ease of better-auth so I think that it should be options to getSessionFromContext and addSessionToRequest.

Originally created by @arthur-fontaine on GitHub (Sep 28, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7 The documentation mentions that better-auth uses cookies to store the session. I never tried, but I think that React Native can't handle server set cookies, and I didn't see anything in the documentation that tells how to change how sessions are stored. So my question is, **_is there a way to use another storage than cookies?_** By reading your code, I think it is only feasible with plugins but not with an option. I guess that if we use plugins, we lose a bit of the ease of better-auth so I think that it should be options to `getSessionFromContext` and `addSessionToRequest`.
GiteaMirror added the locked label 2026-04-13 03:08:43 -05:00
Author
Owner

@Bekacru commented on GitHub (Sep 28, 2024):

You can use the bearer plugin. https://www.better-auth.com/docs/plugins/bearer

It'll allow you to send the session as Authorization Header. Better react native / expo support will be added down the road.

<!-- gh-comment-id:2380401429 --> @Bekacru commented on GitHub (Sep 28, 2024): You can use the bearer plugin. https://www.better-auth.com/docs/plugins/bearer It'll allow you to send the session as Authorization Header. Better react native / expo support will be added down the road.
Author
Owner

@arthur-fontaine commented on GitHub (Sep 28, 2024):

Ah okay, I didn't see it. Thank you!

<!-- gh-comment-id:2380608920 --> @arthur-fontaine commented on GitHub (Sep 28, 2024): Ah okay, I didn't see it. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8086