---
title: "Secrets"
description: "The three keys rsc-kit reads, generating them for production, and rotating one without refusing a request."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.rsc-kit.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Secrets

rsc-kit reads up to three secrets from the environment. Generate each once for
production and keep it in your platform's environment settings:

```sh
openssl rand -base64 32
```

```ini
RSC_HOST_CALL_SECRET=...
RSC_SIGNING_SECRET=...
```

## What each one protects

| Variable | What it protects | Who needs it | Read by |
| --- | --- | --- | --- |
| `RSC_HOST_CALL_SECRET` | calls between the renderer and a Go or Laravel backend | an app with a backend - required | the renderer **and** the backend |
| `RSC_SIGNING_SECRET` | the names a page hands a tab for [`refreshOn`](/guides/live-data) | an app that uses `refreshOn` - required in production | the renderer |
| `RSC_ACTION_ENCRYPTION_KEY` | values a server action sends through the browser, [across a deploy](/hosts/deployment/new-versions/#server-actions-across-a-deploy) | optional | the renderer, from the build |

Each is its own key for its own job. Never reuse one as another, so one
leaking doesn't hand out the rest.

## Generating them

`bun create rsc-kit` and `rsc-kit init` write the first two into `.env` for an
app with a backend, and `php artisan rsc:install` does the same for Laravel.
That is for development. For production, generate each once:

```sh
openssl rand -base64 32
```

Or, without openssl:

```sh
node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"
php -r "echo base64_encode(random_bytes(32)), PHP_EOL;"
```

## Setting them in production

Three rules apply to all of them:

- **The same value on every instance.** Each is checked by a process that may
  not be the one that issued it: a tab served by one renderer, a call landing
  on another backend replica. A value per instance fails for some requests and
  not others.
- **At runtime, from the environment.** The built server reads them when it
  starts, so one build deploys anywhere. `RSC_ACTION_ENCRYPTION_KEY` is the
  exception: set it at build time too.
- **Never in git.** The scaffold's `.gitignore` already leaves out `.env`.

A build carries no backend address and no secret. `RSC_BACKEND`,
`RSC_HOST_CALL_SECRET` and `RSC_SIGNING_SECRET` are read when the server runs,
so rotating a secret is a restart, not a rebuild.

## Rotating one

**Rotating one** is a deploy, and each key rotates differently.

### The host-call secret

The renderer sends it and the backend checks it, so the backend goes first:

```ini
# 1. On the backend
RSC_HOST_CALL_SECRET=<new>
RSC_HOST_CALL_SECRET_PREVIOUS=<old>

# 2. On every renderer
RSC_HOST_CALL_SECRET=<new>

# 3. Once every renderer has it, on the backend: remove RSC_HOST_CALL_SECRET_PREVIOUS
```

Give the backend the new value, with the old one as `RSC_HOST_CALL_SECRET_PREVIOUS`: it answers either.
So no call is refused along the way. The renderer's own health probe takes
either too. This needs `@rsc-kit/core` 0.30.54, `rsc-kit/go` v0.17.0 and
`rsc-kit/laravel` 0.21; before those, the two must change together.

### The signing secret

Pages already open hold names signed with the old key. Keep the old value as
`RSC_SIGNING_SECRET_PREVIOUS` for the deploy that rotates it:

```ini
RSC_SIGNING_SECRET=<new>
RSC_SIGNING_SECRET_PREVIOUS=<old>   # remove it a day later
```

It is accepted when checking a signature and never used to make one, so open
tabs keep refreshing while every page rendered after the rotation carries the
new key. Without it, those tabs stop refreshing until reloaded. Nothing else
breaks.

### The action encryption key

An action called from a page loaded before the change fails. That is the same
window as a deploy without the key pinned; see
[Server actions across a deploy](/hosts/deployment/new-versions/#server-actions-across-a-deploy).

Source: https://docs.rsc-kit.dev/hosts/deployment/secrets/index.mdx
