Liking cljdoc? Tell your friends :D

supabase.auth.session-store

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
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
raw docstring

atom-session-storeclj/s

(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.
sourceraw docstring

local-storage-session-storecljs

(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]))
sourceraw docstring

SessionStoreclj/sprotocol

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-sessionclj/s

(clear-session store)

Removes any persisted session. Returns nil.

Removes any persisted session. Returns nil.

load-sessionclj/s

(load-session store)

Returns the persisted session map, or nil when absent.

Returns the persisted session map, or nil when absent.

save-sessionclj/s

(save-session store session)

Persists session. Returns nil.

Persists `session`. Returns nil.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close