Environment Variables
Learn how to use environment variables in dinou.
Overview
dinou is ready to manage env vars in the code that runs on the Server side (Server Functions, Server Components, and getProps
function).
Setup
Create an .env
file in your project (and add it to your .gitignore
file to not expose sensitive data to the public) and define there your env variables:
# .env
# define here your env vars
MY_VAR=my_value
Usage Example
// In Server Components, Server Functions, or getProps
export async function getProps() {
const myVar = process.env.MY_VAR;
return {
page: { myVar },
layout: { title: "My App" }
};
}