Back
Clerk Wrapper

Clerk Wrapper

Overview

Clerk Wrapper

Clerk is a complete user management platform with embeddable UI components, flexible APIs, and an admin dashboard. It handles authentication, organizations, RBAC, SSO, and billing — so teams can ship secure, production-ready auth without building it from scratch.

The Clerk Wrapper brings your user and organization data into Postgres as queryable foreign tables. Query users, organizations, memberships, invitations, billing subscriptions, and more with plain SQL and join them against your application data. The wrapper works with Supabase Vault for secure API key management and is built on WebAssembly (Wasm) for lightweight, sandboxed execution.

Preparation

Before you get started, make sure the wrappers extension is installed on your database:


_10
create extension if not exists wrappers with schema extensions;

and then enable the Wasm foreign data wrapper:


_10
create foreign data wrapper wasm_wrapper
_10
handler wasm_fdw_handler
_10
validator wasm_fdw_validator;

Secure your credentials (optional)

By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.


_10
select vault.create_secret(
_10
'<Clerk API key>',
_10
'clerk',
_10
'Clerk API key for Wrappers'
_10
);

Connecting to Clerk

We need to provide Postgres with the credentials to access Clerk, and any additional options. We can do this using the create server command:

With Vault:


_10
create server clerk_server
_10
foreign data wrapper wasm_wrapper
_10
options (
_10
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_clerk_fdw_v0.2.1/clerk_fdw.wasm',
_10
fdw_package_name 'supabase:clerk-fdw',
_10
fdw_package_version '0.2.1',
_10
fdw_package_checksum '100f3f105e7e6dab92c433b2da6bec98fafeccd0304e6efaf3780d0a8cae30ec',
_10
api_url 'https://api.clerk.com/v1', -- optional
_10
api_key_id '<key_ID>' -- The Key ID from above.
_10
);

Without Vault:


_10
create server clerk_server
_10
foreign data wrapper wasm_wrapper
_10
options (
_10
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_clerk_fdw_v0.2.1/clerk_fdw.wasm',
_10
fdw_package_name 'supabase:clerk-fdw',
_10
fdw_package_version '0.2.1',
_10
fdw_package_checksum '100f3f105e7e6dab92c433b2da6bec98fafeccd0304e6efaf3780d0a8cae30ec',
_10
api_url 'https://api.clerk.com/v1', -- optional
_10
api_key 'sk_test_...' -- Clerk API key
_10
);

Note: the fdw_package_* options are required and specify the Wasm package metadata. See the Available Versions table above for the full list.

Resources

Details

DeveloperSupabase
DocumentationLearn

Third-party integrations and docs are managed by Supabase partners.

Get started with Clerk Wrapper and Supabase.