serve

14.2.4 • Public • Published

Serve Logo


serve helps you serve a static site, single page application or just a static file (no matter if on your device or on the local network). It also provides a neat interface for listing the directory's contents:

Listing UI

Once it's time to push your site to production, we recommend using Vercel.

Usage

serve v14 onwards requires Node v14 to run. Please use serve v13 if you cannot upgrade to Node v14.

The quickest way to get started is to just run npx serve in your project's directory.

If you prefer, you can also install the package globally (you'll need at least Node LTS):

> npm install --global serve

Once that's done, you can run this command inside your project's directory...

> serve

...or specify which folder you want to serve:

> serve folder-name/

Finally, run this command to see a list of all available options:

> serve --help

Now you understand how the package works! 🎉

Configuration

To customize serve's behavior, create a serve.json file in the public folder and insert any of these properties.

API

The core of serve is serve-handler, which can be used as middleware in existing HTTP servers:

const handler = require('serve-handler');
const http = require('http');

const server = http.createServer((request, response) => {
  // You pass two more arguments for config and middleware
  // More details here: https://github.com/vercel/serve-handler#options
  return handler(request, response);
});

server.listen(3000, () => {
  console.log('Running at http://localhost:3000');
});

You can also replace http.createServer with micro.

Issues and Contributing

If you want a feature to be added, or wish to report a bug, please open an issue here.

If you wish to contribute to the project, please read the contributing guide first.

Credits

This project used to be called list and micro-list. But thanks to TJ Holowaychuk handing us the new name, it's now called serve (which is much more definite).

Author

Leo Lamprecht (@leo)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
14.2.41,350,807latest

Version History

VersionDownloads (Last 7 Days)Published
14.2.41,350,807
14.2.3136,236
14.2.23,296
14.2.1117,976
14.2.053,586
14.1.215,675
14.1.11,333
14.1.0274
14.0.114,165
14.0.025
14.0.0-canary.01
13.0.454,102
13.0.342
13.0.235,445
13.0.116
13.0.080
12.0.148,267
12.0.09,798
11.3.2117,006
11.3.1467
11.3.09,377
11.2.09,151
11.1.01,214
11.0.2434
11.0.13,684
11.0.0147
10.1.23,920
10.1.13,357
10.1.07
10.0.2106
10.0.161
10.0.0756
9.6.01,052
9.4.212
9.4.15
9.4.020
9.3.012
9.2.050
9.1.212
9.1.19
9.1.049
9.0.06
8.2.043
8.1.43
8.1.36
8.1.26
8.1.17
8.1.06
8.0.06
7.2.044
7.1.64
7.1.56
7.1.44
7.1.34
7.1.232
7.1.18
7.1.08
7.0.13
7.0.06
6.5.84,174
6.5.718
6.5.611
6.5.516
6.5.414
6.5.3275
6.5.217
6.5.114
6.5.018
6.4.1111
6.4.107
6.4.935
6.4.819
6.4.77
6.4.69
6.4.55
6.4.47
6.4.318
6.4.24
6.4.141
6.4.08
6.3.136
6.3.07
6.2.020
6.1.017
6.0.6879
6.0.59
6.0.44
6.0.310
6.0.26
6.0.116
6.0.09
5.2.422,431
5.2.36
5.2.29
5.2.15
5.2.07
5.1.567
5.1.412
5.1.34
5.1.214
5.1.19
5.1.07
5.0.418
5.0.319
5.0.25
5.0.19
5.0.08
4.0.222
4.0.19
4.0.08
3.4.17
3.4.04
3.3.15
3.3.011
3.2.107
3.2.98
3.2.86
3.2.75
3.2.67
3.2.55
3.2.414
3.2.35
3.2.24
3.2.13
3.2.07
3.1.04
3.0.26
3.0.120
3.0.012
2.4.423
2.4.34
2.4.25
2.4.15
2.4.07
2.3.08
2.2.04
2.1.28
2.1.17
2.1.05
2.0.06
1.4.0206
1.3.06
1.2.06
1.1.07
1.0.36
1.0.28
1.0.17
1.0.010
0.0.58
0.0.44
0.0.35
0.0.27
0.0.17

Package Sidebar

Install

npm i serve

Weekly Downloads

1,765,332

Version

14.2.4

License

MIT

Unpacked Size

25.8 kB

Total Files

4

Last publish

Collaborators

  • matheuss
  • rauchg
  • timneutkens
  • nick.tracey
  • vercel-release-bot
  • zeit-bot
  • matt.straka
  • bkonkle
  • leo
  • arunoda