GitHub logoGitHub RepoNPM logoNPM Package


The package can be installed through npm (you need to have Node & NPM installed).

npm install @curi/route-active

Prefer inline scripts? A full (.umd.js) and minified (.min.js) script is available for every version through Unpkg. You can access the package's exports through window.CuriRouteActive.


The @curi/route-active package determines whether a route is "active" by comparing it to the current response. This can be restricted to complete matches or allow partial matches so that locations that represent an ancestor of the current location are also considered "active".



A function to create the active route interaction. When you create your router, the result is passed to the router using the `route` option, which will add an active() function to the router's route interactions.

The interaction returns a boolean: true when a route is "active" (it matches the response's location) and false when it does not.

import { createRouter } from "@curi/router";
import active from '@curi/route-active';

const router = createRouter(browser, routes, {
  route: [active()]

const { response } = router.current();

const isActive = router.route.active(
  'Some Route',



The name of the route to check if it is active.


The response to check the route against.


An optional argument with additional properties can be passed as the third argument.

const isActive = router.route.active(
  'Some Route',
    params: { id: 1 },
    partial: false,
    components: location => location.hash === "comments"

Any route params for the route that is being checked.


When true, ancestor routes can be considered active. (default false).


A function that receives a location object and returns a boolean. The default active check only compares the pathname component of the location. This can be useful for checking the other components (hash and query).

This function will only be called when the provided name and params match.