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

plasmajs

v0.1.6

Published

Isomorphic nodeJS framework powered with react

Readme

PlasmaJS

An isomorphic NodeJS framework powered with React for building web apps.

Use the starter-kit to get up and running with PlasmaJS

Features

  • Declarative syntax
  • Isomorphic routing
  • Isolated routing for API endpoints
  • Maintainable middlewares
  • ES6 syntax with babel

Installation

  • Install with npm npm i --save plasmajs(you can also install it globally with npm i -g plasmajs)
  • To run the server, plasmajs path/to/server.js(Add it to your package.json scripts for local install)

Usage

Writing A Server

import React from 'react';

import {
  Server,
  Route, Router,
  NodeHistoryAPI
} from 'plasmajs';

const HeadLayout=    props => (<head><title>{props.title}</title></head>);
const WrapperLayout= props => (<body>{props.children}</body>);
const HomeLayout=    props => (<div>Hello World</div>);
const ErrorLayout=   props => (<div>404 Not Found</div>);

export default class App extends React.Component {

  static get port() { return 8080; }

  render() {
    return (
      <Server>

        <HeadLayout title='Test' />

        <Router
          history={new NodeHistoryAPI(this.props.request, this.props.response)}
          wrapper={WrapperLayout}>

          <Route path='/' component={HomeLayout} />

          <Route errorHandler={true} component={ErrorLayout} />

        </Router>

      </Server>
    );
  }
};

Middlewares

Writing custom middlewares

In MyMiddleWare.jsx...

import { MiddleWare } from 'plasmajs';

export default class MyMiddleWare extends MiddleWare {

  onRequest(req, res) {
    // Do your magic here
    // Run this.terminate() to stop the render and take over
  }
}

And in App's render method...

<Server>
  
  <MyMiddleWare {...this.props} />

  // ...
</Server>

Logger middleware

It logs information about the request made to the server out to the console.

import {Logger} from 'plasmajs' // and add it in the server but after the router declaration.

<Server>
  // ...

  <Logger {...this.props} color={true} />
</Server>
  • Props
    • color (boolean) - Adds color to the logs if true

StaticContentRouter middleware

Allows you to host a static content directory for public files

import {StaticContentRouter} from 'plasmajs'

<Server>
  <StaticContentRouter {...this.props} dir='public' hasPrefix={true} />
  
  // ...
</Server>
  • Props
    • dir (string) - The name of the static content folder to host
    • hasPrefix (boolean) - If set to false, will route it as http://example.com/file instead of http://example.com/public/file
    • compress (boolean) - If true, will enable gzip compression on all static content if the client supports it

APIRoute middleware

Allows you to declare isolated routes for requests to api hooks

import {APIRoute} from 'plasmajs'

//...
  // API request handler for api routes
	_apiRequestHandler() {

    // Return a promise
		return new Promise((resolve, reject) => {
			
      resolve({
        wow: "cool cool"
      });
		});
	}

	render() {
		return (
			<Server>
				<APIRoute {...this.props} method='POST' path='/api/stuff' controller={this._apiRequestHandler} />

				//...
			</Server>
		);
	}
  • Props
    • method (string) - The http request method
    • path (string or regex) - The path to match
    • controller (function) - The request handler

Routing

Isomorphic routing which renders the content on the server-side and then lets the javascript kick in and take over the interactions. (The server side rendering only works for Push State routing on the client side, not Hash routing).

NOTE: Its better to isolate the route definitions to its own file so that the client-side and the server-side can share the components

History API

There are 3 types of routing available - Backend routing(new NodeHistoryAPI(request, response)), Push State routing(new HistoryAPI(options)), Hash routing(new HashHistoryAPI(options))(NOTE: The naming is just for consistency)

The Router

<Router history={history} wrapper={Wrapper}>
  {allRouteDeclarations}
</Router>
  • Props
    • history (object) - It's the history api instance you pass in depending on the kind of routing you require.
    • wrapper (React component class) - It is a wrapper for the routed contents

Declaring a route

If Homepage is a react component class and / is the url.

<Route path='/' component={HomePage} />
  • Props
    • path (string or regex) - The url to route the request to
    • component (React component class) - The component to be rendered when the route is triggered
    • statusCode (integer) - The status code for the response
    • caseInsensitive (boolean) - Set to true if you want the url to be case insensitive
    • errorHandler (boolean) - Set to true to define a 404 error handler