# lws

> A lean, modular web server for rapid full-stack development

Latest version **4.2.1** (published 2026-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install lws
pnpm add lws
yarn add lws
bun add lws
```

Provides the command `lws`.

## Health

**Score 55/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.2.1 |
| Published | 2026-07-06 |
| First published | 2016-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12.20 |
| Dependencies | 14 |
| Unpacked size | 48.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Author | Lloyd Brookes |
| Maintainers | 75lb |
| Keywords | lws, server, http, http2, https, backend, http-server, dev, web |

## Links

- npm: https://www.npmjs.com/package/lws
- Repository: https://github.com/lwsjs/lws
- Homepage: https://github.com/lwsjs/lws#readme
- Issues: https://github.com/lwsjs/lws/issues
- npm.io page: https://npm.io/package/lws

## Dependencies (14)

- [koa](https://npm.io/package/koa.md) ^2.16.4
- [open](https://npm.io/package/open.md) ^8.4.2
- [typical](https://npm.io/package/typical.md) ^7.3.0
- [byte-size](https://npm.io/package/byte-size.md) ^9.0.1
- [walk-back](https://npm.io/package/walk-back.md) ^5.1.2
- [array-back](https://npm.io/package/array-back.md) ^6.2.3
- [load-module](https://npm.io/package/load-module.md) ^5.0.0
- [create-mixin](https://npm.io/package/create-mixin.md) ^3.0.0
- [qrcode-terminal](https://npm.io/package/qrcode-terminal.md) ^0.12.0
- [@75lb/deep-merge](https://npm.io/package/@75lb/deep-merge.md) ^1.1.4
- [command-line-args](https://npm.io/package/command-line-args.md) ^6.0.2
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^7.0.4
- [current-module-paths](https://npm.io/package/current-module-paths.md) ^1.1.3
- [ansi-escape-sequences](https://npm.io/package/ansi-escape-sequences.md) ^6.2.4

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 4.2.1 (latest) — 2026-07-06
- 4.0.0-2 (next) — 2021-06-09
- 4.2.0 — 2024-08-29
- 4.1.5 — 2024-08-01
- 4.1.4 — 2024-07-20
- 4.1.3 — 2024-07-20
- 4.1.2 — 2022-05-28
- 4.1.1 — 2021-10-09
- 4.1.0 — 2021-08-06
- 4.0.2 — 2021-07-15
- 4.0.1 — 2021-07-06
- 4.0.0 — 2021-07-06
- 4.0.0-1 — 2021-06-03
- 4.0.0-0 — 2021-06-02
- 3.1.0 — 2020-05-17
- … 68 more at https://npm.io/package/lws/versions

## README

[![view on npm](https://badgen.net/npm/v/lws)](https://www.npmjs.org/package/lws)
[![npm module downloads](https://badgen.net/npm/dt/lws)](https://www.npmjs.org/package/lws)
[![Gihub repo dependents](https://badgen.net/github/dependents-repo/lwsjs/lws)](https://github.com/lwsjs/lws/network/dependents?dependent_type=REPOSITORY)
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/lwsjs/lws)](https://github.com/lwsjs/lws/network/dependents?dependent_type=PACKAGE)
[![Node.js CI](https://github.com/lwsjs/lws/actions/workflows/node.js.yml/badge.svg)](https://github.com/lwsjs/lws/actions/workflows/node.js.yml)

# lws

A lean, modular web server for rapid full-stack development.

Lws is an application core for quickly launching a local web server. Behaviour is added via plugins giving you full control over how requests are processed and responses created.

* Supports HTTP, HTTPS and HTTP2.
* Small and 100% personalisable. Load and use only the behaviour required by your project.
* Attach a custom view to personalise how activity is visualised.
* Programmatic and command-line APIs.

## Synopsis

### Core usage

Launch an HTTP server on the default port of 8000.

```
$ lws
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000
```

For HTTPS or HTTP2, pass the `--https` or `--http2` flags respectively.

```
$ lws --http2
Listening at https://mba4.local:8000, https://127.0.0.1:8000, https://192.168.0.200:8000
```

Now your server is running, the next step is to attach some middleware to process requests.

### Using middleware plugins

Install and use some middleware ([lws-static](https://github.com/lwsjs/static) and [lws-index](https://github.com/lwsjs/index)) to serve static files and directory listings.

```
$ npm install --save-dev lws-static lws-index

$ lws --stack lws-static lws-index
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000
```

The current directory will now be available to explore at `http://127.0.0.1:8000`.

Install and use logging middleware. Note the `lws-` prefix is optional when supplying module names to `--stack`.

```
$ npm install --save-dev lws-log

$ lws --stack log static index --log.format combined
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000
::ffff:127.0.0.1 - GET /lws.config.js HTTP/1.1 200 52 - 8.259 ms
::ffff:127.0.0.1 - GET /package.json HTTP/1.1 200 399 - 1.478 ms
```

### Creating a custom middleware plugin

Lws uses [Koa](https://github.com/koajs/koa/) as its middleware engine. Here is a trivial plugin example, save the following code as `example-middleware.js`:

```js
class ExamplePlugin {
  middleware () {
    return async (ctx, next) => {
      ctx.body = 'Hello from lws!'
      await next()
    }
  }
}

export default ExamplePlugin
```

Now launch an HTTP server using this middleware.

```
$ lws --stack example-middleware.js
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000

$ curl http://127.0.0.1:8000
Hello from lws!
```

## Install

```
$ npm install --save-dev lws
```

## Documentation

* API Reference
  * [Lws](https://github.com/lwsjs/lws/blob/master/doc/lws.md)
  * [Middleware plugin](https://github.com/lwsjs/lws/blob/master/doc/middleware-plugin.md)
  * [View plugin](https://github.com/lwsjs/lws/blob/master/doc/view-plugin.md)

## See also

* [lws plugin list](https://npms.io/search?q=keywords%3Alws-middleware).
* [local-web-server](https://github.com/lwsjs/local-web-server), an lws distribution with the most common plugins already installed.

* * *

&copy; 2016-26 Lloyd Brookes \<opensource@75lb.com\>.

Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

---
_Source: https://npm.io/package/lws · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
