WHAT YOU'LL LEARN
- How to use environment variables in Webiny - Application-specific variable prefixes - Best practices for sensitive data

Overview
anchor

Environment variables in Webiny are optional for most scenarios. When needed, they follow a prefix-based system that ensures variables are only available to the appropriate application. This prevents accidental exposure of sensitive data between applications.

Application Prefixes
anchor

Webiny uses prefixes to route variables to specific applications:

  • WEBINY_ADMIN_ - Variables for the Admin application
  • WEBINY_API_ - Variables for the API application

Usage
anchor

Setting Variables
anchor

Create a .env file in your project root:

.env

Accessing Variables
anchor

In your extensions, access variables through process.env:

extensions/MyApiExtension.ts
extensions/MyAdminExtension.tsx

TypeScript Support
anchor

Add type definitions for your environment variables:

webiny-env.d.ts

Best Practices
anchor

Security
anchor

  1. Never commit .env - Add to .gitignore
  2. Use prefixes - Isolate sensitive data by application
  3. Rotate secrets - Change production secrets regularly
  4. Minimal exposure - Only set variables that are needed

Documentation
anchor

Create .env.example for team reference:

.env.example

Variable Naming
anchor

Follow consistent naming conventions: