---
title: "Comment by Ashutosh Jha on \"How to use Environment Variables in Vite(React Template Example)\" | Hashnode"
description: "How can I add Environment Variables in Vite React Project in the vite.config.js file import { defineConfig } from &quot;vite&quot;; import react from &quot;@vit"
url: "https://hashnode.com/posts/how-to-use-environment-variables-in-vite-react-template-example/612912d59da1766342ad6b0f/comment/63d492f495d0c71d62c98dd1"
---

[Discussion](https://hashnode.com/posts/how-to-use-environment-variables-in-vite-react-template-example/612912d59da1766342ad6b0f)

Comment [How to use Environment Variables in Vite(React Template Example)](https://hashnode.com/posts/how-to-use-environment-variables-in-vite-react-template-example/612912d59da1766342ad6b0f)

[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/, ""), }, }, }, });
