Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cmorten/refresh

Simple browser reload on file change middleware for your Deno web applications.
https://github.com/cmorten/refresh

deno deno-module denoland

Last synced: 2 months ago
JSON representation

Simple browser reload on file change middleware for your Deno web applications.

Awesome Lists containing this project

README

        

# refresh

Simple browser reload on file change middleware for your Deno web applications.

## Usage

To use `refresh` middleware, just add a few extra lines to your Deno server
implementation:

```ts
import { serve } from "https://deno.land/std/http/server.ts";
import { refresh } from "https://deno.land/x/refresh/mod.ts";

// Create refresh middleware
const middleware = refresh();

serve((req) => {
// In your server handler, just add into the middleware stack!
const res = middleware(req);

if (res) return res;

return new Response("Hello Deno!");
});
```

And add a single `refresh/client.js` script tag anywhere to your HTML:

```html




Example Refresh App



Hello Deno!


```

And you'll get instant browser refresh on every file change for your project 🚀 🚀

## Example

Run the example by cloning this repo locally and executing:

```bash
deno run --allow-net --allow-read ./example/server.ts
```

Open one or more browser tabs on `http://localhost:8000/` and start editing the
`index.html` to see live reloading of all the tabs in the browser.

## Documentation

See [Deno Docs](https://doc.deno.land/https://deno.land/x/refresh/mod.ts).

## License

[MIT License](LICENSE).