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

mobx-state-router

v6.0.1

Published

MobX powered router for React apps

Downloads

6,524

Readme

MobX State Router

npm styled with prettier Travis Coverage Status Commitizen friendly

MobX-powered router for React apps.

Features

  • State is decoupled from the UI. UI is simply a function of the state.
  • UI is no longer responsible for fetching data. Data is now fetched during state transitions using router hooks.
  • The router can override routing requests based on the application state. For example, it can redirect to the Sign In page if the user is not logged in.
  • Supports
    • 404 (Not Found) errors
    • Server-Side Rendering

Learn how to use mobx-state-router in your own project.

Contributors

Make sure all your commit messages conform to the Angular Commit Message Conventions.

To simplify this process, we have included Commitizen as a dependency of this project. Always execute the following command sequence to commit your changes. It will prompt you to fill out any required commit fields interactively.

git add --all
yarn cz-commit # interactive conventional commit
git push

Testing local builds

To test local builds with examples in the examples folder, follow the steps listed below:

  • Build the package
yarn build:local  # creates a dist folder
  • Create a tarball from the package
npm pack  # packages src and dist into a tarball with name [package-name]-[version].tgz
  • Go to an example in the examples directory and add the tarball as a dependency
cd examples/mobx-shop
yarn add ../../[package-name]-[version].tgz
  • Run the example
yarn start

Release to NPM

  • Change the version number in package.json. Use semver. For pre-release versions add a suffix & build number, e.g 5.0.0-beta.1.

  • Commit and push (see above)

  • Build the package

yarn build:local
  • Release to npm
npm publish             # for normal release (adds `latest` tag)
npm publish --tag next  # for pre-release (adds `next` tag)
  • Tag the release and push the tag to remote

Publishing docs to GitHub Pages

Make sure you are connected to GitHub using your SSH key.

cd website
yarn
GIT_USER=nareshbhatia CURRENT_BRANCH=master USE_SSH=true yarn publish-gh-pages

Credits

mobx-state-router is based on ideas from several Open Source projects. I am grateful to the developers of these projects for their contributions. Special thanks go to the following contributions:

How to decouple state and UI (a.k.a. you don’t need componentWillMount)
This article by Michel Weststrate provided the initial inspiration for writing mobx-state-router. It explains the downsides of mixing State and UI and how to untangle the mess!

mobx-router
This library by Kitze is a good implementation of Michel Weststrate's ideas. I have borrowed some concepts from this implementation and then added my own. Thanks Kitze!

router5
This is a more extensive library for routing. It's unique feature is that routes are organized as a tree, made of segments and nodes. It aims to be framework agnostic and uses middleware and plugins to adapt to different frameworks. Of course, with flexibility comes complexity. mobx-state-router makes some choices for you to keep the overall learning curve simple.