Skip to content

A minimal live server for HTML/CSS/JS β€” intended for educational use and in-depth understanding. πŸš€πŸ”₯

License

Notifications You must be signed in to change notification settings

ShayanBlaze/mini-live-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🟒 Mini Live Server (Custom Dev Server with Node.js)

A lightweight, no-dependency development server built with pure Node.js β€” supports live-reloading in the browser on file changes.


πŸš€ Features

  • βœ… Serves static files: HTML, CSS, JS
  • βœ… WebSocket-based auto reload
  • βœ… File change detection with fs.watch
  • βœ… Reloads browser without any plugin or browser extension
  • βœ… No frameworks: built entirely with native http, fs, ws, and path

πŸ“ Project Structure

project-root/
β”œβ”€β”€ server.js              # Main server file
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
└── public/                # Static files served
    β”œβ”€β”€ index.html
    β”œβ”€β”€ styles.css
    └── reload-client.js

πŸ›  How It Works

  1. server.js sets up a Node.js HTTP server
  2. It uses fs.watch() to detect changes in files inside public/
  3. A WebSocket server is created on the same port
  4. When a file changes, a "reload" message is sent to all clients
  5. reload-client.js on the browser listens for this message and calls location.reload()

πŸ“¦ Installation

npm install

Make sure ws and nodemon (optional for development) are listed in your package.json.


▢️ Run the Server

node server.js

Or for development with auto-restart:

nodemon server.js

🧠 Skills Demonstrated

  • Low-level understanding of HTTP server behavior
  • Manual routing and MIME type management
  • Real-time communication via WebSocket
  • File system monitoring with fs.watch
  • Frontend-backend integration without frameworks

πŸ§ͺ Demo Use Case

  1. Open http://localhost:3000 in your browser
  2. Modify index.html or styles.css
  3. The page reloads automatically on file change

πŸ“ Author

Custom-built by Shayan Sharifi as a personal project for understanding real-time development tooling.

Feel free to fork and expand it into your own dev server or tooling system.


βœ… License

MIT

About

A minimal live server for HTML/CSS/JS β€” intended for educational use and in-depth understanding. πŸš€πŸ”₯

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published