# pjax-pwa-overlay

> A set of mustache templates to be used with express-mustache-overlays and bootstrap-flexbox-overlay that add PJAX (PushState+AJAX) and Progressive Web App support to a project.

Latest version **0.2.3** (published 2019-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install pjax-pwa-overlay
pnpm add pjax-pwa-overlay
yarn add pjax-pwa-overlay
bun add pjax-pwa-overlay
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2019-02-15 |
| First published | 2019-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 57.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | JimmyG |
| Maintainers | thejimmyg |

## Links

- npm: https://www.npmjs.com/package/pjax-pwa-overlay
- Repository: https://github.com/thejimmyg/pjax-pwa-overlay
- Homepage: https://github.com/thejimmyg/pjax-pwa-overlay#readme
- Issues: https://github.com/thejimmyg/pjax-pwa-overlay/issues
- npm.io page: https://npm.io/package/pjax-pwa-overlay

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^4.1.0

## Recent versions

- 0.2.3 (latest) — 2019-02-15
- 0.2.1 — 2019-02-15
- 0.2.0 — 2019-02-15
- 0.1.0 — 2019-02-12

## README

# PJAX PWA Overlay

A set of mustache templates to be used with express-mustache-overlays and bootstrap-flexbox-overlay that add PJAX (PushState+AJAX) and Progressive Web App support to a project.

## Configuration

The components in this package make use of the `app.locals.pjaxPwa` namespace.

## Example

See `./example` for a full example and tutorial.

## Environment Variables

All the environment variables from express-render-error, express-mustache-overlays and express-public-files-overlays are available in the example, but the following are also available from `bootstrapOptionsFromEnv()`:

* `NETWORK_ERROR_URL` - the URL the PWA should fetch to use in case there is a network error in future
* `START_URL` - the URL the PWA should fetch to use each time the site is opened (after the user has installed the app)
* `WITH_PJAX_PWA` - enable or disable the PJAX PWA support, defaults to `'true'`, set to `'false'` to disable PWA support
* `WITH_START_PAGE` - setup a route handler at the `startUrl` that renders the template `start` to generate the start page. Defaults to `true`.
* `WITH_NETWORK_ERROR_PAGE` - setup a route handler at the `networkErrorUrl` that renders the template `networkError` to generate the network error page. Defaults to `true`.
* `START_PAGE_TITLE` - The title of the start page. Defaults to `'Start'`.
* `NETWORK_ERROR_PAGE_TITLE` - The title of the network error page. Defaults to `'Network Error'`


## PJAX Links and Forms

All links within `<div id="pjax-container">` will automatically use PJAX (as long as you have `WITH_PJAX_PWA='true'` set).

Any form given the ID `data-pjax` will be submitted as multipart via PJAX too. **Only one form per page can have this ID though**. The express-mustache-jwt-signin package's sign in form already has this ID for example.

Since forms are submitted as multipart, you'll need to install middleware that
can parse that and make it available as `req.body`. For example busboy.

**Tip: Debugging PJAX requests can be tricky because the default behaviour if there is an error is to re-fetch and re-load the entire page. To be able to track down errors more easily in your browser, make sure you tick the `Preserve Log` checkbox in the network tab and console so that you can see the failed request as well as the successfull request afterwards.**


## Dev

```
npm run fix
```


## Changelog

### 0.2.3 2019-02-15

* Changed `setupPjaxPwa()` so that `withPjaxPwa` defaults to `true`
* Added `withStartPage` and `withNetworkErrorPage` with default values of `true` to the config options you can pass to `setupPjaxPwa()`
* Added `NETWORK_ERROR_PAGE_TITLE` and `START_PAGE_TITLE`
* Added default config options

### 0.2.1 2019-02-15

* Changed `setupPjaxPwa()` so that any config specified overrides the values in `app.locals.theme` and `app.locals.pjaxPwa` for the purposes of setting up the PJAX PWA
* Updated the example so that it caches the public files it needs using service worker

### 0.2.0 2019-02-15

* Make `WITH_PJAX_PWA` `true` by default
* Provide deafault icon192 URL and icon

### 0.1.0 2019-02-06

* First version

---
_Source: https://npm.io/package/pjax-pwa-overlay · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
