Skip to content

Simple boilerplate for localserver which refreshes site in browser when edited code is saved.

Notifications You must be signed in to change notification settings

janpi242/simple-node-reload-and-refresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-node-reload-and-refresh

Simple skeleton for sketch projects which refreshes both app and result in browser. browser-refresh is used to accomplish it. You can find more info here.

Installing and running

git clone https://github.com/janpi242/simple-node-reload-and-refresh.git
cd simple-node-reload-and-refresh
npm i
npm run dev

Using with node 'express'

If you are using 'express' use it like this:

const express = require('express')
const app = express()

app.get('/', (req, res) => {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/html; charset=UTF-8');
    res.write('<h1>Auto refresh</h1>')
    res.write(`<script src=${process.env.BROWSER_REFRESH_URL}></script>`);
    res.end();
});

app.listen(port, hostname, () => {
    console.log(`Server running at http://${hostname}:${port}/`)

    if (process.send) {
        process.send({ event: 'online', url: 'http://localhost:3000/' })
    }
})

About

Simple boilerplate for localserver which refreshes site in browser when edited code is saved.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published