Liking cljdoc? Tell your friends :D

supabase.core.client

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

supabase.core.error

Anomaly-based error handling for the Supabase Clojure SDK.

Errors are represented as plain maps following the cognitect/anomalies convention. This avoids tagged tuples and exceptions by default, matching the data-driven philosophy of libraries like cognitect/aws-api.

Anomaly Categories

The SDK maps HTTP status codes and domain errors to these categories:

  • :cognitect.anomalies/incorrect — bad request, validation failure (4xx client errors)
  • :cognitect.anomalies/forbidden — authentication/authorization failure (401, 403)
  • :cognitect.anomalies/not-found — resource not found (404)
  • :cognitect.anomalies/conflict — resource already exists (409)
  • :cognitect.anomalies/busy — rate limited, resource locked (423, 429)
  • :cognitect.anomalies/unavailable — server error, service unavailable (5xx)
  • :cognitect.anomalies/fault — unexpected server-side failure

Structure

An anomaly map always contains :cognitect.anomalies/category and may include:

  • :cognitect.anomalies/message — human-readable error description
  • :supabase/service — originating service (:auth, :storage, etc.)
  • :supabase/code — semantic error code keyword (e.g. :not-found)
  • :http/status — original HTTP status code
  • :http/body — response body (parsed or raw)
  • :http/headers — response headers

Usage

(require '[supabase.core.error :as error])

;; Check if a result is an error
(error/anomaly? result)

;; Create an anomaly from an HTTP response
(error/from-http-response 404 {:message "Not Found"} :storage)

;; Create a domain-specific anomaly
(error/anomaly :cognitect.anomalies/incorrect
  {:supabase/service :auth
   :cognitect.anomalies/message "Invalid credentials"})
Anomaly-based error handling for the Supabase Clojure SDK.

Errors are represented as plain maps following the cognitect/anomalies convention.
This avoids tagged tuples and exceptions by default, matching the data-driven
philosophy of libraries like cognitect/aws-api.

## Anomaly Categories

The SDK maps HTTP status codes and domain errors to these categories:

  - `:cognitect.anomalies/incorrect`   — bad request, validation failure (4xx client errors)
  - `:cognitect.anomalies/forbidden`   — authentication/authorization failure (401, 403)
  - `:cognitect.anomalies/not-found`   — resource not found (404)
  - `:cognitect.anomalies/conflict`    — resource already exists (409)
  - `:cognitect.anomalies/busy`        — rate limited, resource locked (423, 429)
  - `:cognitect.anomalies/unavailable` — server error, service unavailable (5xx)
  - `:cognitect.anomalies/fault`       — unexpected server-side failure

## Structure

An anomaly map always contains `:cognitect.anomalies/category` and may include:

  - `:cognitect.anomalies/message` — human-readable error description
  - `:supabase/service`            — originating service (`:auth`, `:storage`, etc.)
  - `:supabase/code`               — semantic error code keyword (e.g. `:not-found`)
  - `:http/status`                 — original HTTP status code
  - `:http/body`                   — response body (parsed or raw)
  - `:http/headers`                — response headers

## Usage

    (require '[supabase.core.error :as error])

    ;; Check if a result is an error
    (error/anomaly? result)

    ;; Create an anomaly from an HTTP response
    (error/from-http-response 404 {:message "Not Found"} :storage)

    ;; Create a domain-specific anomaly
    (error/anomaly :cognitect.anomalies/incorrect
      {:supabase/service :auth
       :cognitect.anomalies/message "Invalid credentials"})
raw docstring

supabase.core.http

Composable HTTP request builder and executor for Supabase services.

Requests are built as plain maps using a threading-friendly API, then executed synchronously via Hato. This is the backbone that all service modules (auth, storage, postgrest, functions, realtime) use internally.

Request Map Structure

A request map contains:

  • :method — HTTP method keyword (:get, :post, :put, :patch, :delete)
  • :url — fully resolved URL string
  • :headers — map of header name to value
  • :query — map of query parameter name to value
  • :body — request body (map, string, or nil)
  • :service — originating service keyword (:auth, :storage, etc.)
  • :client — reference to the client map

Usage

(require '[supabase.core.http :as http])

;; Build and execute a request
(-> (http/request client)
    (http/with-service-url :auth-url "/signup")
    (http/with-method :post)
    (http/with-body {:email "user@example.com" :password "secret"})
    (http/execute))

;; Returns {:status 200, :body {...}, :headers {...}} on success
;; Returns anomaly map on HTTP error (status >= 400)

;; Throwing variant for those who prefer exceptions
(-> (http/request client)
    (http/with-service-url :auth-url "/signup")
    (http/with-method :post)
    (http/with-body {:email "user@example.com" :password "secret"})
    (http/execute!))

;; Async variant returning CompletableFuture
(-> (http/request client)
    (http/with-service-url :functions-url "/hello")
    (http/with-method :post)
    (http/with-body {:name "world"})
    (http/execute-async))
Composable HTTP request builder and executor for Supabase services.

Requests are built as plain maps using a threading-friendly API, then
executed synchronously via Hato. This is the backbone that all service
modules (auth, storage, postgrest, functions, realtime) use internally.

## Request Map Structure

A request map contains:

  - `:method`    — HTTP method keyword (`:get`, `:post`, `:put`, `:patch`, `:delete`)
  - `:url`       — fully resolved URL string
  - `:headers`   — map of header name to value
  - `:query`     — map of query parameter name to value
  - `:body`      — request body (map, string, or nil)
  - `:service`   — originating service keyword (`:auth`, `:storage`, etc.)
  - `:client`    — reference to the client map

## Usage

    (require '[supabase.core.http :as http])

    ;; Build and execute a request
    (-> (http/request client)
        (http/with-service-url :auth-url "/signup")
        (http/with-method :post)
        (http/with-body {:email "user@example.com" :password "secret"})
        (http/execute))

    ;; Returns {:status 200, :body {...}, :headers {...}} on success
    ;; Returns anomaly map on HTTP error (status >= 400)

    ;; Throwing variant for those who prefer exceptions
    (-> (http/request client)
        (http/with-service-url :auth-url "/signup")
        (http/with-method :post)
        (http/with-body {:email "user@example.com" :password "secret"})
        (http/execute!))

    ;; Async variant returning CompletableFuture
    (-> (http/request client)
        (http/with-service-url :functions-url "/hello")
        (http/with-method :post)
        (http/with-body {:name "world"})
        (http/execute-async))
raw 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