https://github.com/nativew/serve
🍛 Ultralight http server with live reload. [CLI + API]
https://github.com/nativew/serve
command-line dev hot http live node refresh reload server static
Last synced: about 15 hours ago
JSON representation
🍛 Ultralight http server with live reload. [CLI + API]
- Host: GitHub
- URL: https://github.com/nativew/serve
- Owner: nativew
- License: isc
- Created: 2021-01-19T04:18:23.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-05T09:14:12.000Z (almost 4 years ago)
- Last Synced: 2025-09-04T15:40:11.373Z (9 months ago)
- Topics: command-line, dev, hot, http, live, node, refresh, reload, server, static
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 29
- Watchers: 1
- Forks: 14
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Serve 🍛
Ultralight http server with live reload.
CLI + API
### Simple CLI and API
### With live reload
### Light and modern
### No dependencies
### One command
```zsh
npm init serve
```
### Or one function
```js
import serve from 'create-serve';
serve.start();
```
### To start 🍛
### CLI
By default, it serves `public` if the folder exists, otherwise root `/`.
Or you can specify a different folder.
```zsh
npm init serve [folder]
```
### API
```js
import serve from 'create-serve';
serve.start({
port: 7000,
root: '.',
live: true
});
```
### Live reload
```js
serve.update();
```
### Use any file watcher
[Chokidar](https://github.com/paulmillr/chokidar)
```js
import serve from 'create-serve';
import chokidar from 'chokidar';
serve.start();
chokidar.watch('.').on('change', () => {
serve.update();
});
```
[esbuild](https://esbuild.github.io/api/#watch)
Use the official wrapper for esbuild's watch → [esbuild-serve](https://github.com/nativew/esbuild-serve)
### Log
Import the util functions to log updates with colours.
```js
import serve, { error, log } from 'create-serve';
serve.update();
hasError
? error('× Failed') // Red
: log('✓ Updated'); // Green
```