Skip to main content
A Function can read only the Secrets that you attach to it. When an invocation starts, Browserbase loads the attached values into context.secrets. Before you begin, create a Secret and create a Functions project with the Functions quickstart. The SDK examples use @browserbasehq/sdk for Node.js and browserbase for Python.

Attach and use a Secret

1

Read the Secret in the handler

Read the value from context.secrets with the name that you chose when you created the Secret:
Node.js
Function Secrets are not environment variables. Read attached Secrets from context.secrets, not process.env.
2

Publish the Function

Publish the entrypoint:
The command prints the Function ID. Save it for the next step.
3

Attach the Secret

Pass the Function ID and Secret ID:
The Function and Secret must belong to the same Browserbase project.The list contains metadata only. It does not contain Secret values.
4

Invoke the Function

Invoke the deployed Function:
Browserbase loads the attached values when the invocation starts. The handler reads them from context.secrets.
Function attachments apply only to deployed invocations. The local development server does not load them.Use a local environment variable as a development fallback:
Node.js
Don’t commit local secret values or .env files.

Update an attached Secret

Update the Secret by ID:
The update keeps the same Secret ID and Function attachments. New invocations use the new value.

Detach a Secret

Remove the Function’s access without deleting the Secret:
Later invocations no longer receive the detached Secret.

Troubleshooting

Next steps

Manage Secrets

Create, inspect, update, and delete Secrets.

Invoke a Function

Pass parameters and retrieve asynchronous results.