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 🙏

© 2024 – Pkg Stats / Ryan Hefner

electrode-react-webapp-multipage

v0.0.6

Published

Hapi/Express/Koa plugin that provides a default React web app template

Downloads

2

Readme

Electrode React Webapp Multipage (on development)

NPM version Dependency Status devDependency Status npm downloads

This is a Hapi plugin that register a default route for your Webapp to return a bootstrapping React application. With support for webpack dev server integrations.

This repo was forked from electrode react-webapp package

##What has changed? You can use a custom html file inside a path for templating purposes. It's an optional property, so, if you don't override this property, it will use the default one.

Installing

npm install electrode-react-webapp-multipage --save

Usage

Registering with Hapi

You can use this plugin by registering it with your Hapi server.

const reactWebapp = server.register({
  register: require("electrode-react-webapp-multipage"),
  options: {
    pageTitle: "My Awesome React WebApp",
    paths: {
      "/{args*}": {
        view: "index",
        htmlFile: "{{MY_SRC_PATH}}", (optional)
        content: "<h1>Hello React!</h1>"
    }
  }
});

Registering with electrode-server

To use this with electrode-server, add to the config you pass to electrode-server:

const config = {
  plugins: {
    "electrode-react-webapp-multipage": {
      options: {
        pageTitle: "My Awesome React WebApp",
        paths: {
          "/{args*}": {
            view: "index",
            htmlFile: "{{MY_SRC_PATH}}", (optional)
            content: "<h1>Hello React!</h1>"
        }
      }
    }
  }
}

require("electrode-server")(config);

Default options

This plugin has some default options but you can override them by setting your own value.

The current defaults are:

{
  pageTitle: "Untitled Electrode Web Application",
  webpackDev: process.env.WEBPACK_DEV === "true",
  renderJS: true,
  serverSideRendering: true,
  htmlFile: "node_modules/electrode-react-webapp-multipage/lib/index.html",
  devServer: {
    host: "127.0.0.1",
    port: "2992"
  },
  paths: {},
  stats: "dist/server/stats.json"
}

Options

What you can do with the options:

  • pageTitle (String) The value to be shown in the browser's title bar
  • webpackDev (Boolean) whether to use webpack-dev-server's URLs for retrieving CSS and JS bundles.
  • serverSideRendering (Boolean) Toggle server-side rendering.
  • htmlFile (String) Absolute or relative path to the application root html file. It must contains the following placeholders:
    • {{PAGE_TITLE}} page title.
    • {{WEBAPP_BUNDLES}} injected <script> and <link> tags to load bundled JavaScript and Css
    • {{PREFETCH_BUNDLES}} <script> tag containing code that will contains prefetched JavaScript code
    • {{SSR_CONTENT}} injected content rendered on server side
  • paths (Object) An object of key/value pairs specifying paths within your application with their view and (optionally) initial content for server-side render
    • path (Object)
      • view (String) Name of the view to be used for this path required
      • content Content to be rendered by the server when server-side rendering is used optional see details
  • devServer (Object) Options for webpack's DevServer
    • host (String) The host that webpack-dev-server runs on
    • port (String) The port that webpack-dev-server runs on

Content details

The content you specify for your path can either be a string or a promise returning function.

If it's a string, it's treated as a straight React template to be rendered.

If it's a function, the function should return a promise that resolves an object:

function myContent() {
  return Promise.resolve({
    status: 200,
    html: "<h1>Hello React!</h1>",
    prefetch: ""
  });
}