Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/cmorten/refresh
- Owner: cmorten
- License: mit
- Created: 2022-01-02T13:55:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-28T09:43:18.000Z (11 months ago)
- Last Synced: 2024-10-04T15:53:42.153Z (3 months ago)
- Topics: deno, deno-module, denoland
- Language: TypeScript
- Homepage: https://deno.land/x/refresh
- Size: 11.7 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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).