Skip to content

About

A complete Toolkit to interact with Supabase APIs from Clojure

Topics

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Supabase Clojure

Supabase Community Clojure SDK

;; deps.edn
{:deps
  {io.github.supabase-community/core      {:mvn/version "0.3.0"}  ;; base SDK
   io.github.supabase-community/auth      {:mvn/version "0.1.0"}  ;; auth integration
   io.github.supabase-community/postgrest {:mvn/version "0.1.0"}  ;; postgrest integration
   io.github.supabase-community/storage   {:mvn/version "0.1.0"}  ;; storage integration
   io.github.supabase-community/functions {:mvn/version "0.1.0"}  ;; edge functions integration
   io.github.supabase-community/realtime  {:mvn/version "0.1.0"}}} ;; realtime integration

Individual product client documentation:

Task-oriented recipes (ClojureScript setup, MFA recovery codes, bucket lifecycle rules, object versioning): Cookbook

Clients

A Supabase client is a plain immutable Clojure map holding general information about your Supabase project. It can be passed to any of the service modules (auth, storage, postgrest, etc.) to interact with the corresponding API.

Usage

To create a client:

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

(supabase/make-client "https://<supabase-url>" "<supabase-api-key>")
;; => {:base-url "https://..." :api-key "..." :auth-url "..." ...}

Any additional config can be passed as keyword arguments:

(supabase/make-client "https://<supabase-url>" "<supabase-api-key>"
  :db {:schema "another"}
  :auth {:flow-type "pkce"}
  :global {:headers {"custom-header" "custom-value"}})

Initialized clients are plain maps with no managed state.

Error Handling

Errors are represented as cognitect/anomalies maps instead of exceptions. Check results with error/anomaly?:

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

(let [result (some-operation)]
  (if (error/anomaly? result)
    (println "Error:" (:cognitect.anomalies/message result))
    (println "Success:" (:body result))))

Development

Run from the repo root — root deps.edn and tests.edn aggregate every module:

# Run all tests across modules (Kaocha)
clojure -M:test

# Check formatting (cljfmt)
clojure -M:fmt check core/src core/test auth/src auth/test

# Fix formatting
clojure -M:fmt fix core/src core/test auth/src auth/test

Each module also has its own :test alias, so cd core && clojure -M:test works for module-scoped runs.

License

MIT

About

A complete Toolkit to interact with Supabase APIs from Clojure

Topics

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages