Token Configuration
Using .env.local
Store your Tinybird token in a.env.local file in your project root:
.env.local
tinybird.config.json
Using .env
The SDK also loads.env files. Priority order:
.env.local(highest priority).env
process.env values are preserved and not overwritten.
.env
Environment Variable Interpolation
The SDK supports${VAR_NAME} syntax for interpolating environment variables in JSON config files:
tinybird.config.json
Validation
If a referenced environment variable is not set, the SDK will throw an error:JavaScript Config Files
For.mjs and .cjs config files, use process.env directly:
tinybird.config.mjs
Multiple Tokens
You can use different tokens for different environments:.env.local
Next.js Integration
Next.js automatically loads.env.local and .env files. The Tinybird CLI does too, so no additional setup is needed:
package.json
Token Scopes
Different operations require different token scopes:READ
Query datasources and endpoints
APPEND
Ingest data into datasources
ADMIN
Create JWT tokens, manage resources
DATASOURCES:WRITE
Create and modify datasources
Creating Tokens
Via CLI
Use the interactive login flow to create and store tokens:- Opens your browser for authentication
- Saves the token to
.env.local - Updates
baseUrlin your config if needed
Via Dashboard
Create tokens manually in the Tinybird dashboard:- Go to Tokens section
- Click Create Token
- Select scopes
- Copy the token to
.env.local
JWT Tokens
Create short-lived JWT tokens for frontend applications:JWT tokens are useful for multi-tenant applications requiring row-level security or time-limited access from browsers.
Environment-Specific Configuration
Use different.env files per environment:
CI/CD Integration
In CI/CD pipelines, set environment variables directly rather than using.env files:
- GitHub Actions: Repository secrets
- GitLab CI: CI/CD variables
- Vercel: Environment variables
- Netlify: Build environment variables
Security Best Practices
Never commit tokens
Add
.env.local and .env to .gitignoreUse token rotation
Regularly rotate tokens in production
Limit token scopes
Use minimum required scopes for each token
Use JWT for clients
Create short-lived JWT tokens for frontend apps