# @btwiuse/serve

> 🍛 Ultralight http server with live reload. [CLI + API]

Latest version **1.0.2** (published 2022-06-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install @btwiuse/serve
pnpm add @btwiuse/serve
yarn add @btwiuse/serve
bun add @btwiuse/serve
```

Provides the command `create-serve`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-06-17 |
| First published | 2022-06-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Btwiuse Arch |
| Maintainers | btwiuse |
| Keywords | serve, cli, command-line, http, https, dev, development, server, livereload, live, reload, hot, spa, refresh |

## Links

- npm: https://www.npmjs.com/package/@btwiuse/serve
- Repository: https://github.com/btwiuse/serve
- npm.io page: https://npm.io/package/@btwiuse/serve

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-06-17
- 1.0.1 — 2022-06-08

## README

<div></div>

# Serve 🍛

Ultralight http server with live reload.  
<sub><code>CLI + API</code></sub>

<br>

### Simple CLI and API

### With live reload

### Light and modern

### With secure protocol

### With SPA support

### No dependencies

<br>

### One command

```zsh
npm init serve
```

<br>

### Or one function

```js
import serve from 'create-serve';

serve.start();
```

<br>

### To start 🍛

<br>

### CLI

By default, it serves `public` if the folder exists, otherwise root `/`.  
Or you can specify a different folder.

```zsh
npm init serve [folder]
```

<br>

### API

```js
import serve from 'create-serve';

serve.start({
    host: 'localhost',
    port: 7000,
    root: '.',
    live: true,
    fallback: 'index.html',
    isHttps: true,
    tlsOptions: {
      key: 'absolute path to private key',
      cert: 'absolute path to cert',
    },
});
```

<br>

### Live reload

```js
serve.update();
```

<br>

### Use any file watcher

<br>

[Chokidar](https://github.com/paulmillr/chokidar)

```js
import serve from 'create-serve';
import chokidar from 'chokidar';

serve.start();

chokidar.watch('.').on('change', () => {
    serve.update();
});
```

<br>

[esbuild](https://esbuild.github.io/api/#watch)

Use the official wrapper for esbuild's watch &nbsp; → &nbsp; [esbuild-serve](https://github.com/nativew/esbuild-serve)

<br>

### 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
```

<br><br>

<p>
    <a href="https://github.com/nativew/nativeweb">
        <img src="https://raw.githubusercontent.com/nativew/nativeweb/1e9405c629e3a6491bb59df726044eb3823967bb/logo-square_nativeweb.svg" alt="Native Web" width="80px">
    </a>
</p>

<div></div>

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