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 Function secrets are not environment variables. Read attached secrets from
context.secrets with the name that you chose when you created the secret:Node.js
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.
- Browse CLI
- Node.js
- Python
4
Invoke the Function
Invoke the deployed Function:Browserbase loads the attached values when the invocation starts. The handler reads them from
context.secrets.Test during local development
Test during local development
Function attachments apply only to deployed invocations. The local development server does not load them.Use a local environment variable as a development fallback:Don’t commit local secret values or
Node.js
.env files.Update an attached secret
Update the secret by ID:Detach a secret
Remove the Function’s access without deleting the secret:- Browse CLI
- Node.js
- Python
Troubleshooting
Next steps
Manage secrets
Create, inspect, update, and delete secrets.
Invoke a Function
Pass parameters and retrieve asynchronous results.