koa-push
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Koa Push

Build Status

Koa middleware for handling client-side pushstate routes. By default, a push state request is any GET request that has no file extension and doesn't begin with /api/.

Install

npm install koa-push

Usage

import koaPushState from 'koa-push';
 
app.use(koaPushState('/path/to/index.html'));

Alternatively, you can pass your own check to determine if the request should be handled by the push state middleware:

import koaPushState, { isPushStateRouteDefault } from 'koa-push';
 
app.use(
  koaPushState(
    '/path/to/index.html',
    context =>
      isPushStateRouteDefault(context) ||
      context.request.path.startsWith('/routes/')
  )
);

Readme

Keywords

Package Sidebar

Install

npm i koa-push

Weekly Downloads

106

Version

1.0.4

License

ISC

Unpacked Size

11.2 kB

Total Files

12

Last publish

Collaborators

  • simplej