npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leajs-spa-router

v0.1.0

Published

npm version minor

Readme

leajs-spa-router

Plugin of leajs.

Single page router.

Features

  • Injects client side router into your routes
  • Fallback to server side router for SEO or when no JS allowed
  • Routes get bundled to save traffic
  • Supports critical css (see get-critical-css)
  • Supports localized routes
  • Can serve polyfills depending on JS functionality
  • Supports webpack manifest and chunk manifest

leajs.config

module.exports = {

  // Configuration of spa router
  // type: Object
  spaRouter: {

    // Namespace for the router e.g. /spa
    base: "", // String

    // Inject the client-router directly. True will inject a <script> and expose the file. When set to False, you are responsible to deliver the client, e.g. by using Webpack and `require('leajs-spa-router')`.
    client: "inject", // [String, Boolean]

    // criticalCss options
    criticalCss: false, // [Object, Boolean]

    // Name of critical css file
    // Default: _critical
    criticalCss.critical: null, // String

    // Folder where critical/uncritical files are
    // Default: app_build/
    criticalCss.folder: null, // String

    // Resolve hashed uncritical css file. See https://github.com/paulpflug/get-critical-css#hash
    // Default: true
    criticalCss.hashed: null, // Boolean

    // Vame of uncritical css file
    // Default: _uncritical
    criticalCss.uncritical: null, // String

    // Default route
    default: "/", // String

    // Default folder for all routes. When using `locale` you can provide a function, e.g: (locale) => {"app/${locale}"}
    folder: "app/", // [String, Function]

    // Filename for empty url
    index: "index", // String

    // Default inject property for all routes. Each route with 'inject:true' will be included in all responses. Reduces requests, but costs more bandwidth.
    inject: true, // Boolean

    // Spa-router plugins to use. Absolute or relative to CWD path.
    // Default:
    plugins: null, // Array

    // Conditional deliver polyfills
    // Default: Promise polyfill yaku
    // type: Object
    // $item ([String, Object]) Polyfill config object, can be used for a shortcut of `spaRouter.polyfills.$item.check`
    // $item.url (String) Url to deliver, will overwrite object key
    // $item.check (String) JS condition to check in browser befor polyfill will be fetched
    // $item.file (String) File to deliver
    polyfills: null, // Object

    // Redirect all unresolved requests to default route
    redirect: true, // Boolean

    // Name of the root file
    root: "root", // String

    // Routes lookup, will be merged into content of the routes file, if available
    // $item (Object) a single route
    // $item.file ([String, Function]) filename to load. When using `locale` you can provide a function, e.g: (locale) => {"file.${locale}"}
    // $item.folder ([String, Function]) Overwrites default folder option
    // $item.inject (Boolean) Overwrites default inject option
    // $item.transform (String) Overwrites default transform option
    routes: null, // Object

    // Name of routes file
    routesFile: "routes.config", // String

    // Folders to search for routes file
    routesFolder: ["./server","./"], // [String, Array]

    // Name of a jstransformer to use by default. E.g. 'pug', would need `jstransformer-pug` to be installed
    transform: null, // String

    // Options object for jstransformers
    transformOptions: {"cache":false}, // Object

    // Id of view element
    view: "view", // String

    // Watch routes.config file for changes
    // Default: not inProduction
    watch: null, // Boolean

  },

  // Configuration object
  // type: Object
  webpack: {

    // Filename of webpack chunk manifest file
    // Default: Deactivated, when activated defaults to 'chunk-manifest.json'
    chunkManifest: null, // [String, Boolean]

    // Filename of webpack manifest file
    // Default: Deactivated, when activated defaults to 'manifest.json'
    manifest: null, // [String, Boolean]

    // Output folder of webpack
    // Default: Read from webpack.config 'output.path'
    output: null, // String

  // …

}

routes.config

Read by read-conf, from ./ or ./server/ by default.

module.exports = {
  "/someRoute": {
    // Clientside: will be called after routing
    after: null, // Function

    // Clientside: will be called before routing
    before: null, // Function

    // filename to load. When using `locale` you can provide a function, e.g: (locale) => {"file.${locale}"}
    // Default: name of the route
    file: null, // [String, Function]

    // Overwrites default folder option
    folder: null, // [String, Function]

    // Overwrites default inject option
    inject: null, // Boolean

    // Overwrites default transform option
    transform: null, // String
  },

  // …

}

License

Copyright (c) 2018 Paul Pflugradt Licensed under the MIT license.