Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

serve

> 开发工具
Open source

Static file serving and directory listing

9.9K stars0 likes1 views
WebsiteGitHub

About

Static file serving and directory listing


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:

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):

bash
> npm install --global serve

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

bash
> serve

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

bash
> serve folder-name/

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

bash
> serve --help

Now you understand how the package works! :tada:

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:

javascript
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)

Issues· 152 open

View all issuesOpen on GitHub
  • #862

    Allow JSON schema property in `serve.json`

    Updated Sep 27, 2026
  • #855

    Fallback for SPA should support files other than index.html

    Updated Jun 25, 2026
  • #819

    Checking for updates failed

    Updated May 8, 2026
  • #792

    add --open to the CLI

    Updated Mar 25, 2026
  • #808

    `npx serve .` does not always serve the current directory

    Updated Mar 18, 2026
  • #799

    `localhost:1234/foo/index.html.html` provokes a 404

    Updated Feb 4, 2026
  • #784

    Testing local deployments for GitHub pages doesn't work since no `basePath` can be set

    Updated Jan 30, 2026
  • #772

    Remove auto redirect

    Updated Jan 12, 2026
  • #838

    Release notes automation for Serve

    Updated Dec 27, 2025
  • #837

    EMFILE: too many open files

    Updated Dec 26, 2025

> Tags

TypeScriptclicommandhttpnode

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具