Getting Started
1. Declare A Secret
Section titled “1. Declare A Secret”Declare the secret in application code and register it with the backend app.
import { backend } from "@layeron/core"import { secret } from "@layeron/modules"
const app = backend()
const stripeSecret = secret.static({ name: "stripe-secret", namespace: "billing",})
app.use(stripeSecret)2. Consume The Secret
Section titled “2. Consume The Secret”Use the Secret product object from a route or product integration.
app.post("/billing/customer", async () => { const apiKey = await stripeSecret.current().text()
return { configured: apiKey.length > 0, }})High-level helpers are available for signing and verification:
const sessionKey = secret.random({ name: "session-key", namespace: "auth",})
app.use(sessionKey)
app.post("/session", async () => { return { token: await sessionKey.signJwt({ sub: "user_123" }, { expiresIn: "30m" }), }})3. Set A Cloudflare Secret
Section titled “3. Set A Cloudflare Secret”For direct Cloudflare deploys, write the value into the user’s Cloudflare Secrets Store:
layer secret set STRIPE_SECRET --value-env STRIPE_SECRETThe command uses Cloudflare credentials from layer login.
Next Steps
Section titled “Next Steps”- Values and versioning: Use static, random, generated, and versioned secret values.
- Cloudflare values: Write deploy values, local CLI values, versioned values, and generated rotations.
- Rotation: Configure rotation intervals, retention modes, direct deploy behavior, and rotation state.
- API reference: Review Secret options, value formats, ownership, consume settings, and module methods.