# elysia-hot-module-reload

> An [Elysia](https://elysiajs.com/) plugin that enables hot module reloading in the browser for local development!

Latest version **1.0.1** (published 2023-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install elysia-hot-module-reload
pnpm add elysia-hot-module-reload
yarn add elysia-hot-module-reload
bun add elysia-hot-module-reload
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-10-06 |
| First published | 2023-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | dadajian |

## Links

- npm: https://www.npmjs.com/package/elysia-hot-module-reload
- Repository: https://github.com/danadajian/elysia-hot-module-reload
- Homepage: https://github.com/danadajian/elysia-hot-module-reload#readme
- Issues: https://github.com/danadajian/elysia-hot-module-reload/issues
- npm.io page: https://npm.io/package/elysia-hot-module-reload

## Recent versions

- 1.0.1 (latest) — 2023-10-06
- 1.0.0 — 2023-10-06

## README

# elysia-hot-module-reload

An [Elysia](https://elysiajs.com/) plugin that enables hot module reloading in the browser for local development!

## Basic Usage With React

```tsx
import Elysia from "elysia";
import { hotModuleReload, HotModuleReload } from "elysia-hot-module-reload";
import { renderToReadableStream } from "react-dom/server";

function App() {
  return <div>Hello world!</div>;
}

const app = new Elysia()
  .get("*", async (context) => {
    const stream = await renderToReadableStream(
      <>
        <App />
        <HotModuleReload />
      </>,
    );
    return new Response(stream, {
      headers: { "Content-Type": "text/html" },
    });
  })
  .use(hotModuleReload())
  .listen(3000);

console.info(
  `App is running at http://${app.server?.hostname}:${app.server?.port}`,
);
```

### Custom Websocket Path

```tsx
import Elysia from "elysia";
import { hotModuleReload, HotModuleReload } from "elysia-hot-module-reload";
import { renderToReadableStream } from "react-dom/server";

function App() {
  return <div>Hello world!</div>;
}

const customWebSocketPath = "my-custom-path";

const app = new Elysia()
  .get("*", async (context) => {
    const stream = await renderToReadableStream(
      <>
        <App />
        <HotModuleReload webSocketPath={customWebSocketPath} />
      </>,
    );
    return new Response(stream, {
      headers: { "Content-Type": "text/html" },
    });
  })
  .use(hotModuleReload({ webSocketPath: customWebSocketPath }))
  .listen(3000);

console.info(
  `App is running at http://${app.server?.hostname}:${app.server?.port}`,
);
```

[Example usage with React + SSR!](https://github.com/danadajian/elysia-hot-module-reload/blob/main/example/server.tsx)

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