Client configuration for interacting with Supabase.
Creates and manages immutable client maps containing connection options, service URLs, and configuration for your Supabase project. The client is a plain Clojure map validated with Malli schemas.
(require '[supabase.core.client :as client])
;; Create a client with defaults
(client/make-client "https://abc.supabase.co" "my-api-key")
;; Create a client with options
(client/make-client "https://abc.supabase.co" "my-api-key"
:db {:schema "another"}
:auth {:flow-type "pkce"}
:global {:headers {"custom-header" "custom-value"}})
;; Update the access token for authenticated requests
(client/update-access-token client "new-token")
{:base-url "https://abc.supabase.co"
:api-key "my-api-key"
:access-token "my-api-key"
:auth-url "https://abc.supabase.co/auth/v1"
:database-url "https://abc.supabase.co/rest/v1"
:storage-url "https://abc.supabase.co/storage/v1"
:functions-url "https://abc.supabase.co/functions/v1"
:realtime-url "https://abc.supabase.co/realtime/v1"
:db {:schema "public"}
:global {:headers {"x-client-info" "supabase-clj/0.2.0"}}
:auth {:auto-refresh-token true, :flow-type "implicit", ...}
:storage {:use-new-hostname false}}
See https://supabase.com/docs/reference/javascript/initializing
Client configuration for interacting with Supabase.
Creates and manages immutable client maps containing connection options,
service URLs, and configuration for your Supabase project. The client is
a plain Clojure map validated with Malli schemas.
## Usage
(require '[supabase.core.client :as client])
;; Create a client with defaults
(client/make-client "https://abc.supabase.co" "my-api-key")
;; Create a client with options
(client/make-client "https://abc.supabase.co" "my-api-key"
:db {:schema "another"}
:auth {:flow-type "pkce"}
:global {:headers {"custom-header" "custom-value"}})
;; Update the access token for authenticated requests
(client/update-access-token client "new-token")
## Client Map Structure
{:base-url "https://abc.supabase.co"
:api-key "my-api-key"
:access-token "my-api-key"
:auth-url "https://abc.supabase.co/auth/v1"
:database-url "https://abc.supabase.co/rest/v1"
:storage-url "https://abc.supabase.co/storage/v1"
:functions-url "https://abc.supabase.co/functions/v1"
:realtime-url "https://abc.supabase.co/realtime/v1"
:db {:schema "public"}
:global {:headers {"x-client-info" "supabase-clj/0.2.0"}}
:auth {:auto-refresh-token true, :flow-type "implicit", ...}
:storage {:use-new-hostname false}}
See https://supabase.com/docs/reference/javascript/initializingSchema for auth configuration options.
Schema for auth configuration options.
Schema for the full Supabase client map.
Schema for the full Supabase client map.
Schema for database configuration. Defaults to the "public" schema.
Schema for database configuration. Defaults to the `"public"` schema.
(ensure-client client)Returns nil if client matches the Client schema, otherwise an anomaly.
Returns nil if `client` matches the Client schema, otherwise an anomaly.
Schema for supported auth flow types.
Schema for supported auth flow types.
Schema for global client options, including default HTTP headers.
Schema for global client options, including default HTTP headers.
(make-client base-url api-key & {:as opts})Creates a new Supabase client map from a base URL and API key.
The client is a plain immutable map containing all configuration needed to
interact with Supabase services. Service URLs are derived from base-url.
By default, the access-token is set to the api-key.
Returns the client map on success, or an anomaly map on validation failure.
:access-token — override the default access token (defaults to api-key):db — database options, e.g. {:schema "another"}:global — global options, e.g. {:headers {"x-custom" "val"}}:auth — auth options, e.g. {:flow-type "pkce"}:storage — storage options, e.g. {:use-new-hostname true}(make-client "https://abc.supabase.co" "my-key")
(make-client "https://abc.supabase.co" "my-key"
:db {:schema "private"}
:auth {:flow-type "pkce" :debug true})
Creates a new Supabase client map from a base URL and API key.
The client is a plain immutable map containing all configuration needed to
interact with Supabase services. Service URLs are derived from `base-url`.
By default, the `access-token` is set to the `api-key`.
Returns the client map on success, or an anomaly map on validation failure.
## Options (keyword args)
- `:access-token` — override the default access token (defaults to `api-key`)
- `:db` — database options, e.g. `{:schema "another"}`
- `:global` — global options, e.g. `{:headers {"x-custom" "val"}}`
- `:auth` — auth options, e.g. `{:flow-type "pkce"}`
- `:storage` — storage options, e.g. `{:use-new-hostname true}`
## Examples
(make-client "https://abc.supabase.co" "my-key")
(make-client "https://abc.supabase.co" "my-key"
:db {:schema "private"}
:auth {:flow-type "pkce" :debug true})Schema for storage configuration options.
Schema for storage configuration options.
(transform-storage-url storage-url)Transforms a storage URL to use the storage subdomain for official Supabase domains.
Official domains (.supabase.co, .supabase.in, .supabase.red) are rewritten
to route through storage.supabase.*. Custom domains, localhost, IPs, and URLs
already using the storage subdomain are returned unchanged.
(transform-storage-url "https://abc.supabase.co/storage/v1")
;; => "https://abc.storage.supabase.co/storage/v1"
(transform-storage-url "https://custom.example.com/storage/v1")
;; => "https://custom.example.com/storage/v1"
Transforms a storage URL to use the storage subdomain for official Supabase domains.
Official domains (`.supabase.co`, `.supabase.in`, `.supabase.red`) are rewritten
to route through `storage.supabase.*`. Custom domains, localhost, IPs, and URLs
already using the storage subdomain are returned unchanged.
(transform-storage-url "https://abc.supabase.co/storage/v1")
;; => "https://abc.storage.supabase.co/storage/v1"
(transform-storage-url "https://custom.example.com/storage/v1")
;; => "https://custom.example.com/storage/v1"(update-access-token client access-token)Returns a new client with the given access-token swapped in.
Returns an anomaly map if client is not a valid client map.
(update-access-token client "new-jwt-token")
Returns a new client with the given `access-token` swapped in.
Returns an anomaly map if `client` is not a valid client map.
(update-access-token client "new-jwt-token")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 |