---
title: "Discussion on \"Using Vite to Serve and Hot-Reload React App & Express API Together\" | Hashnode"
description: "Discussion on \"Using Vite to Serve and Hot-Reload React App & Express API Together\". Vite is a fast and lightweight build tool for modern JavaScript applications. It is designed to be simple to use and easy to configure, with a focus on providing a smooth developer experience.\nWe love developing with Vite because it's fast and easy t..."
url: "https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb"
---

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

Discussion

# [Using Vite to Serve and Hot-Reload React App & Express API Together](https://noam.hashnode.dev/using-vite-to-serve-and-hot-reload-react-app-express-api-together?utm_source=hashnode&utm_medium=feed)

Vite is a fast and lightweight build tool for modern JavaScript applications. It is designed to be simple to use and easy to configure, with a focus on providing a smooth developer experience. We love developing with Vite because it's fast and easy t...

Jan 29, 2023 · 5 min read · noam.hashnode.dev  
Read the article

-   [#web-development](https://hashnode.com/tag/web-development)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#full-stack](https://hashnode.com/tag/full-stack)
-   [#nodejs](https://hashnode.com/tag/nodejs)

## Written by

[noam honig](https://hashnode.com/@noamhonig)

@noamhonig

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

Creator of remult.dev

Coder, open-sourcerer, developer experience enthusiast, software architect, and entrepreneur. @FireflyMigration, I oversee and consult in legacy modernization of large-scale complex enterprise applications for fortune 500s to small businesses, for &gt;15 years. As a volunteer developer, I love helping NGOs with full-stack TypeScript development and mentoring. Creator of remult.dev

## Responses 6

Markdown supported · ⌘↵ to post

[Alex Waldmann](https://hashnode.com/@RockyWearsAHat)

[Mar 13, 2024](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/65f13e2f65a9a9c863a6c4fb)

This is crazy, I was told by my instructor that there wasn't really a good way to run express and react on the same port via vite. This post is absolute gold, besides some slight issues setting this up, I ported my app running hono to running express in about an hour, maybe two. This is very helpful, incredibly insightful, and overall, I learned a couple things reading and implementing this. Who knew server.ssrLoadModule was a thing? Certainly not me, thank you for sharing this information freely it was a great read and extremely helpful to get my project up and running again.

I made an account just to like and comment on this post, thank you

[David](https://hashnode.com/@davidhikesalot)

[Feb 28, 2024](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/65df7982de9e22dc566d8197)

I'm curious how you would dockerize this. Everyone seems to take the approach of pulling express out into a separate port, but could logic here keep it simple?

[noam honig](https://hashnode.com/@noamhonig)

[Feb 29, 2024](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/65df7982de9e22dc566d8197#reply-65e023fc191323cfffffaf82)

Hi David, I use vite as a development server - it was not intended as a production server. When I build it for production, vite generates a set of static files that are more efficient, and I use Express to serve these files.

Here's a link to a YouTube video where I do that live on stage: [youtu.be/TEtr9-WRGvU](https://youtu.be/TEtr9-WRGvU?si=IceCaVOp36nqzynA)

You can jump to minute 31 where I prepare the app for deployment and deploy it.

[Dominic Victoria](https://hashnode.com/@hunkoys)

[Dec 8, 2023](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/6573615c17e07d7a03564b29)

Hi [noam honig](https://hashnode.com/@noamhonig), I'm trying to figure out to build both frontend and the server. I changed the config to start from both files but the transpiled server.js won't run.

[noam honig](https://hashnode.com/@noamhonig)

[Dec 9, 2023](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/6573615c17e07d7a03564b29#reply-65740a1917e07d7a035a2838)

Hi [D](https://hashnode.com/@bix922) can you share an example where you run into this problem - I would love to help.

I have a tutorial if you want at: [remult.dev/docs](https://remult.dev/docs/)

You can also reach out to me on discord at: [discord.gg/GXHk7ZfuG5](https://discord.gg/GXHk7ZfuG5)

[Emil Welton](https://hashnode.com/@emil98)

[Aug 29, 2023](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/64ed4bdc3a8717415f5e1785)

Noam, you are my hero. I'm working on a side project to flesh out my resume a little bit, and I spent about 8 hours today searching for a simple way to develop a React + Node app using vite and tailwind CSS and miraculously you answered all my questions in this article. And then I checked the comments and you answered the very next question I had regarding the environment variables! You earned a follow with this one :)

[Adam Kościelniak](https://hashnode.com/@Tackgnol)

[May 18, 2023](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/64661a21eb43c7e4ebcfef04)

I like this, but one problem with this solution: If I want to have variables for my backend like keys for my DB I have to use the VITE\_ pattern which makes it also visible on the front-end :(.

Any solution for that?

[noam honig](https://hashnode.com/@noamhonig)

[May 18, 2023](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/64661a21eb43c7e4ebcfef04#reply-646620a0eb43c7e4ebcfeff4)

I solved that using 'dotenv'

And placing these variables in a .env file - like I would do in my node js server

```
import {config} from 'dotenv'
config()
console.log({ test: process.env["TESTING123"] })
```

.env

```
TESTING123=works
```

[Piotr Dros](https://hashnode.com/@Dros)

[Apr 26, 2023](https://hashnode.com/posts/using-vite-to-serve-and-hot-reload-react-app-express-api-together/63d676ef0eee226dca3e4fcb/comment/6448f67cb0864d740aabf2bf)

I really like the way you combine vite build tool with running server separately, but I really like keeping client side files and server side files disctinct. How can I achive that keeping vite build tool as runner for the server?

The strcuture would look something like this: . ├── etc... ├── src │ ├── client │ └── server ├── tsconfig.json └── vite.config.ts
