Pluggable session persistence for Supabase Auth.
The auth functions are stateless: the caller owns the session map
returned by sign-in / verify-otp / refresh-session. This namespace
provides a small protocol for persisting that session between process
restarts (or, on ClojureScript, page reloads), matching the client's
:auth :persist-session / :storage-key configuration.
Implementations:
atom-session-store — in-memory atom. Both platforms; the
default choice on the JVM.local-storage-session-store — browser localStorage,
ClojureScript only. Keyed by the client's :auth :storage-key.(def store (session-store/atom-session-store))
(session-store/save-session store (:body (auth/sign-in-with-password c creds)))
(session-store/load-session store) ;; => session map or nil
(session-store/clear-session store) ;; sign-out
Pluggable session persistence for Supabase Auth.
The auth functions are stateless: the caller owns the session map
returned by sign-in / `verify-otp` / `refresh-session`. This namespace
provides a small protocol for persisting that session between process
restarts (or, on ClojureScript, page reloads), matching the client's
`:auth :persist-session` / `:storage-key` configuration.
Implementations:
- [[atom-session-store]] — in-memory atom. Both platforms; the
default choice on the JVM.
- `local-storage-session-store` — browser `localStorage`,
ClojureScript only. Keyed by the client's `:auth :storage-key`.
## Example
(def store (session-store/atom-session-store))
(session-store/save-session store (:body (auth/sign-in-with-password c creds)))
(session-store/load-session store) ;; => session map or nil
(session-store/clear-session store) ;; sign-out(atom-session-store)Returns a SessionStore backed by an in-memory atom. Sessions do not
survive process restarts (JVM) or page reloads (ClojureScript); use it as
the default on the JVM and for tests everywhere.
Returns a [[SessionStore]] backed by an in-memory atom. Sessions do not survive process restarts (JVM) or page reloads (ClojureScript); use it as the default on the JVM and for tests everywhere.
(local-storage-session-store)(local-storage-session-store key)Returns a SessionStore backed by browser localStorage, persisting
the session across page reloads. key defaults to
"supabase.auth.token"; pass the client's :auth :storage-key to
share the slot with other tooling:
(local-storage-session-store (get-in client [:auth :storage-key]))
Returns a [[SessionStore]] backed by browser `localStorage`, persisting
the session across page reloads. `key` defaults to
`"supabase.auth.token"`; pass the client's `:auth :storage-key` to
share the slot with other tooling:
(local-storage-session-store (get-in client [:auth :storage-key]))Session persistence contract. session is the token payload the auth
server returns (the :body of sign-in / verify-otp / refresh-session
responses); implementations store and return it as a plain map, or nil
when absent.
Session persistence contract. `session` is the token payload the auth server returns (the `:body` of sign-in / verify-otp / refresh-session responses); implementations store and return it as a plain map, or nil when absent.
(clear-session store)Removes any persisted session. Returns nil.
Removes any persisted session. Returns nil.
(load-session store)Returns the persisted session map, or nil when absent.
Returns the persisted session map, or nil when absent.
(save-session store session)Persists session. Returns nil.
Persists `session`. Returns nil.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |