RealComposer
Upstream APIsOfficial Clerk docs

Clerk Safe & Unsafe Practices

Direct Answer

Clerk publishable keys (pk_) are meant for frontends, while secret keys (sk_) call the Backend API and must stay server-side. Verify session tokens on the server, and authorize from public or private metadata only, because unsafeMetadata can be edited by the user.

Credentials & Where They Belong

Client safe
Publishable key (pk_)

Initializes Clerk components in the browser or app.

Server only
Secret key (sk_)

Reads and manages every user, session, and organization.

Safe Practices

  • Verify session JWTs on the server

    Use networkless verification with your instance public key before trusting a user ID.

  • Store roles in private or public metadata

    Only the Backend API can write those fields, so they are safe for authorization.

Unsafe Practices

  • Authorizing from unsafeMetadata

    Users can set unsafeMetadata from the frontend and grant themselves roles.

  • Trusting a user ID sent in the request body

    Derive identity from the verified session token, not client input.

  • Calling the Backend API from client code

    It requires the secret key, which would then be public.

The RealComposer Pattern

Store CLERK_SECRET_KEY in the vault and expose a pipeline that returns only safe user fields, such as display name and plan, for a verified session.

START BUILDING FREE

Frequently Asked Questions

Q:Is the Clerk publishable key safe to expose?

Yes. It only identifies your Clerk instance to frontend SDKs.

Combine intercom users with clerk user metadata

Clerk user profile and Intercom contact record stitched for in-app chat. For "combine intercom users with clerk user metadata", store INTERCOM_ACCESS_TOKEN, CLERK_SECRET_KEY in Secret Vault, call https://api.intercom.io/contacts from a Worker, and let React / Flutter / Mobile hit only https://realcomposer.com/v1/workspace/combine-intercom-with-clerk-users with an rc_live_ client token.

Sub-10ms edgeView Recipe
Multi-API Aggregation

Stitch firebase with clerk session bootstrap

Clerk session and Firebase FCM registration merged at startup. For "stitch firebase with clerk session bootstrap", store FIREBASE_ACCESS_TOKEN, CLERK_SECRET_KEY in Secret Vault, call https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}} from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/stitch-firebase-with-clerk-bootstrap with an rc_live_ client token.

Sub-10ms edgeView Recipe

Related Concepts