Fundamentals
Quickstart
Get started with fatima in minutes.
Init CLI
Use this if you want to skip directly to using a config file.
Next steps in this page will cover a quickstart with no config file.
pnpm add -D fatimanpm install -D fatimayarn add -D fatimaInstallation
pnpm add -D fatimanpm install -D fatimayarn add -D fatimaCreate a .env file
Create a .env file in the root of your project:
PORT=3000
NODE_ENV=development
TZ=UTC
NEXT_PUBLIC_URL=http://localhost:3000Generate types
This will produce a env.ts file based on the variables in your .env file, with the correct types.
pnpm fatima generatePath Alias
Make sure you can import env from anywhere in your project without big relative imports:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"env": ["./env.ts"]
}
}
}{
"imports": {
"#env": "./env.js"
}
}{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#env": ["./env.js"]
}
}
}Add env to your .gitignore
You should gitignore your env and always generate it before building/installing.
env.tsenv.jsGo on and use it
import { env } from "env";
import { Response } from "server";
export async function GET() {
// Full intellisense 👇
const port = env.PORT;
return Response(port);
}