---
title: "Discussion on \"How to use Environment Variables in Vite(React Template Example)\" | Hashnode"
description: "Discussion on \"How to use Environment Variables in Vite(React Template Example)\". Using environment variables when working with reactjs template inside Vite"
url: "https://hashnode.com/posts/how-to-use-environment-variables-in-vite-react-template-example/612912d59da1766342ad6b0f"
---

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

Discussion

# [How to use Environment Variables in Vite(React Template Example)](https://blog.ramadevsign.com/how-to-use-environment-variables-in-vite-react-template-example?utm_source=hashnode&utm_medium=feed)

Using environment variables when working with reactjs template inside Vite

Aug 27, 2021 · 2 min read · blog.ramadevsign.com  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#reactjs](https://hashnode.com/tag/reactjs)

## Written by

[Ramadevsign (Rama Ochieng)](https://hashnode.com/@RamaSpeaksDevsign)

@RamaSpeaksDevsign · EMEA (GMT - GMT+3)

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

Devsigner(Developer & Designer) | Open Source Contributor

I am a Designer and Front End developer creating beautiful experiences online

## Responses 2

Markdown supported · ⌘↵ to post

[Ashutosh Jha](https://hashnode.com/@ashutosh887)

[Jan 28, 2023](https://hashnode.com/posts/how-to-use-environment-variables-in-vite-react-template-example/612912d59da1766342ad6b0f/comment/63d492f495d0c71d62c98dd1)

How can I add Environment Variables in Vite React Project in the vite.config.js file

import { defineConfig } from "vite"; import react from "@vitejs/plugin-react";

const proxy\_url = "[localhost/";](http://localhost:5000/%22;)

export default defineConfig({ plugins: \[react()\], server: { proxy: { "/api": { target: proxy\_url, changeOrigin: true, rewrite: (path) => path.replace(/^/api/, ""), }, }, }, });

[Ogochukwu Azubogu](https://hashnode.com/@OgochukwuAzubogu)

[Jun 29, 2022](https://hashnode.com/posts/how-to-use-environment-variables-in-vite-react-template-example/612912d59da1766342ad6b0f/comment/62bc1bb09c913efac56c8f5b)

This was a huge help. Thanks.✨
