# How to Hide API Keys in Framer Websites

> Framer generates pure React client components where hardcoded API keys are visible to anyone viewing browser source code. Route requests through RealComposer to inject secrets at the edge and enforce domain origin protection.

- Canonical page: https://realcomposer.com/recipes/hide-api-key-framer
- Client platform: Framer
- Upstream services: OpenAI, Airtable, Resend
- Category: Security & Secret Vault
- JSON version: https://realcomposer.com/recipes/hide-api-key-framer.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=hide-api-key-framer&via=agent

## Problem: Framer Code Components Run Exclusively in the Browser

Framer code overrides and components compile into browser-executed JavaScript with zero server privacy.

- Leaked API keys in public JS bundles
- Quota theft by competitors
- CORS blocking from third-party APIs

## Solution steps

1. **Store Secret in RealComposer**: Save private API token in AES-256 Vault.

2. **Fetch from Framer Component**: Call RealComposer endpoint using public token.

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Framer Edge Proxy",
  "method": "POST",
  "cacheTtlSeconds": 0,
  "steps": [
    {
      "stepKey": "resend",
      "upstreamUrlTemplate": "https://api.resend.com/emails",
      "httpMethod": "POST",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.RESEND_API_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "messageId",
        "sourceStep": "resend",
        "sourcePath": "id"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X POST "https://realcomposer.com/v1/acme/framer-email"
```

## Payload before and after

Raw upstream response:

```json
{
  "id": "email_99a8",
  "from": "hello@startup.com",
  "to": [
    "user@example.com"
  ]
}
```

Slimmed RealComposer response:

```json
{
  "messageId": "email_99a8"
}
```

## FAQ

### Can I restrict calls to my Framer domain?

Yes, RealComposer client tokens allow strict origin whitelisting.
