Call Clerk Backend API from Client Side
Vault-backed Clerk proxy tuned for Frontend / Web
Never place CLERK_SECRET_KEY inside Frontend / Web source. RealComposer injects them when calling https://api.clerk.com/v1/users/{{query.userId}}, so browsers see only a client token.
Clerk keys in Frontend / Web network tabs
Frontend / Web ships code or scripts to end-user devices. Any Clerk bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.
- Shared Frontend / Web projects revealing Clerk tokens
- Sudden Clerk quota burn from scripted abuse
- Inability to rotate keys without redeploying clients
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Create CLERK_SECRET_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Target the real upstream URL
Point step clerk at https://api.clerk.com/v1/users/{{query.userId}} with GET. Add output mapping fields that mirror the JSON contract your screen already expects. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).
Call from Frontend / Web
Call https://realcomposer.com/v1/workspace/clerk-backend-api-proxy with a restricted rc_live_ client token. Frontend / Web never sends upstream secrets.
const res = await fetch('https://realcomposer.com/v1/workspace/clerk-backend-api-proxy', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_clerk-ba",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "clerk-backend-api-proxy"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"userId": "sample",
"email": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 242 B to 36 B (-85%)
curl -X GET "https://realcomposer.com/v1/workspace/clerk-backend-api-proxy" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Does Frontend / Web need CORS changes after adding RealComposer?
Yes for clerk-backend-api-proxy. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects CLERK_SECRET_KEY on https://api.clerk.com/v1/users/{{query.userId}}.
What cache key does RealComposer use?
clerk-backend-api-proxy forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.
How do I rotate upstream credentials?
Upstream steps in clerk-backend-api-proxy honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
- DefinitionMulti-Tenant API
- DefinitionPKCE (Proof Key for Code Exchange)
- DefinitionJSON Web Token (JWT)
- DefinitionCSRF Protection
- DefinitionRefresh Token
- DefinitionToken Introspection
- DefinitionSAML Single Sign-On
- DefinitionWebAuthn and Passkeys
- DefinitionSingle Sign-On (SSO)
- DefinitionHTTP Strict Transport Security (HSTS)
- DefinitionHttpOnly Cookies
- DefinitionSameSite Cookies
- DefinitionOpaque Access Token
- DefinitionFederated Identity
- DefinitionMFA for API Access
- DefinitionReplay Attack Prevention
- DefinitionCryptographic Nonce
- DefinitionBreak-Glass Access
- DefinitionClient Certificates
- Stack guideWeb Frontends safe & unsafe practices
- Stack guideClerk safe & unsafe practices
- Official docsWeb Frontends documentation
- Official docsClerk documentation
Deploy this Frontend / Web + Clerk Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.