---
title: "Discussion on \"Managing multiple environments in NestJS\" | Hashnode"
description: "Discussion on \"Managing multiple environments in NestJS\". Development, test, staging, production environment variables"
url: "https://hashnode.com/posts/managing-multiple-environments-in-nestjs/611c0724888ca15f5d392f35"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Managing multiple environments in NestJS](https://petroskyriakou.hashnode.dev/managing-multiple-environments-in-nestjs?utm_source=hashnode&utm_medium=feed)

Development, test, staging, production environment variables

Aug 17, 2021 · 7 min read · petroskyriakou.hashnode.dev  
Updated Aug 24, 2021  
Read the article

-   [#nest](https://hashnode.com/tag/nest)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Petros Kyriakou](https://hashnode.com/@pitops)

@pitops

  
[View profile](https://hashnode.com/@pitops)

Full Stack Dev

## Responses 1

Markdown supported · ⌘↵ to post

[Benjamin Klotz](https://hashnode.com/@tak1n)

[Aug 24, 2021](https://hashnode.com/posts/managing-multiple-environments-in-nestjs/611c0724888ca15f5d392f35/comment/6125265fb115357df05f4614)

Glad to see someone else had the same requirements in regards to managing environments and environment variables in NestJS. What we ended up using was [nest-typed-config](https://github.com/Nikaple/nest-typed-config#using-multiple-loaders) with its multiple loaders approach.

Basically we have 4 different config files:

-   base.yml (shared across all environments)
-   development.yml
-   test.yml
-   production.yml

We still leverage the env var loader with highest precedence to adhere to 12factor principles, while providing sane defaults to ease the setup and being developer friendly.

[Petros Kyriakou](https://hashnode.com/@pitops)

[Aug 24, 2021](https://hashnode.com/posts/managing-multiple-environments-in-nestjs/611c0724888ca15f5d392f35/comment/6125265fb115357df05f4614#reply-61253b0fb115357df05f48c3)

Interesting, thanks for sharing. From what i can understand the main selling point is type safety and flexibility on loaders?

[Benjamin Klotz](https://hashnode.com/@tak1n)

[Aug 24, 2021](https://hashnode.com/posts/managing-multiple-environments-in-nestjs/611c0724888ca15f5d392f35/comment/6125265fb115357df05f4614#reply-61255d1e663d427e19ffb1b8)

[Petros Kyriakou](https://hashnode.com/@pitops) yes exactly, also doing validation/transformation through class-validator/class-transformer, but validation is also possible in the official NestJS config module through Joi like you outlined in your great article :)
