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

dev-bar

v0.0.1

Published

A toolbar at the bottom of your React apps with useful information.

Downloads

3

Readme

dev-bar

A toolbar to connect your server to React

image

The toolbar shows a few key stats out of the box. If you're using express as a backend, you'll automatically get the request time (req) and response time (res). This one is probably less helpful, but it's there. Also included by default is the currently checked out git branch.

Usage

React

Import the component, and add it to your root component. It can go anywhere, but inside App is probably more semantic.

import { DevToolbar } from 'dev-bar';
...

export default props => {
  <div>
    <p>My Cool App</p>
    <DevToolbar />
  </div>
}

To not include the entire package in your client (until treeshaking gets better in webpack), you can also do

import DevToolbar from 'dev-bar/dist/DevToolbar';

Express

The toolbar exposes a pretty basic middleware on the express side.

import { middleware as devToolbarMiddleware } from 'dev-bar';
...

const app = express();
app.use(devToolbarMiddleware());

Similarly to above, you can import this directly to reduce the size of your dependencies, but this shouldn't make too much different on a server.

import devToolbarMiddleware from 'dev-bar/dist/middleware';

To add your own values, pass an object into the middleware. You can either pass in raw values, or functions. One day soon, promises, too. If you want to get things out of the req or res, they're passed into your functions.

app.use(devToolbarMiddleware({
  loggedIn: req => !!req.user,
  apiVersion: 2,
}));

This will add loggedIn: true / apiVersion: 2 to your toolbar. Any values that exist as null or undefined will show up as 'undefined'.

Not using Express?

You can use whatever backend you like, but you'll need to implement the socket connection yourself. The default port is 3001. If you want a different port, pass in a port prop to the Toolbar component. You just need to emit an object under 'devUpdate'. Each key in the object will become a key in the toolbar. Keep it light.

To bind your socket to a different port, i.e. http://localhost:8080:

// import the DevToolbar component
<DevToolbar port={8080} />

Alternatively, if you want to specify a different URL completely, pass in the url prop. Note: this will override the port, if any is passed in.