meiosis-router Documentation

⬆ Contents Setup / Hash Mode

Overview

meiosis-router sets up a router that uses Meiosis to produce route-related data to be stored in the application state.

Concepts

The Meiosis pattern updates application state which is then used render the view. meiosis-router complements this concept by also using application state to drive routing.

meiosis-router provides:

meiosis-router coordinates between application state and routes:

meiosis-router can be set up to work one of two modes:

Hash Mode:

History Mode:

When setting up meiosis-router, we provide a mapping that associates route paths to strings that identify the route.

Route paths are strings that start with a slash, such as '/', '/login', /user/settings, and so on. Route paths can contain one or more route parameters, indicated with a : prefix, such as /user/:id.

meiosis-router also supports query parameters, which are additional parameters provided at the end of the URL in the form of ?key1=value1&key2=value2.

Route

meiosis-router produces Route objects of the following shape:

{
  value: string,
  params: Object,
  replace: boolean
}

Using this information, we can perform tasks upon route change, such as loading data, and we can render application views according to the current route.

⬆ Contents Setup / Hash Mode

Meiosis is developed by foxdonut (Twitter / GitHub) and is released under the MIT license.