no-internet-web-craft
v1.0.9
Published
Craft your No Internet or Page Not Found web page
Downloads
6
Maintainers
Readme
no-internet-web-craft
If you want to craft the browser default no-internet page according to your design, You can use this libaray. This will library make sure to show your crafted page whenever any document page will not loaded.
Pre-requirements:
- Download the sw.js file
- Put this file inside your project root directory, the name must be same as sw.js
- Create and design a html file which you want to show when internet issue or server unavaialbe. (like no-internet.html)
- Put this file inside your project root directory.
How to use
Install the package using npm or script: npm install
NPM
Install using npm:
npm i no-internet-web-craft
Initialisation in ESM style
import NoInternetWebCraft from 'no-internet-web-craft';
const wc = new NoInternetWebCraft('/no-internet.html', '1.0.0')
wc.initWebSocket().then((res) => {
if (res.status === 'success') {
console.log('Service worker activated')
} else {
console.log('Service worker activation failed')
}
})
UMD
Put this script tag inside your tag:
<script src="https://www.unpkg.com/[email protected]/umd/no-internet-web-craft.min.js"></script>
Initialisation in UMD style
The NoInternetWebCraft constructor function will available at the global lavel.
const wc = new NoInternetWebCraft('/no-internet.html', '1.0.0')
wc.initWebSocket().then((res) => {
if (res.status === 'success') {
console.log('Service worker activated')
} else {
console.log('Service worker activation failed')
}
})