Skip to content

routeConfig

Global route configuration.
This object contains all global options for some behaviour of route and router instances

Basic example

ts
import { routeConfig, createBrowserHistory } from "mobx-route";

const history = createBrowserHistory()

routeConfig.update({
  history,
  baseUrl: '/',
});

routeConfig.get();

Fields

history

This is interface History from mobx-location-history package.
API is identical with history NPM package

Example:

ts
import {
  createHashHistory,
  createBrowserHistory,
  createMemoryHistory,
} from "mobx-location-history";

routeConfig.update({
  history: createHashHistory(),
  history: createBrowserHistory(),
  history: createMemoryHistory(),
})

TIP

Factory functions for this property is also can be exported from mobx-route package.

ts
import {
  createHashHistory,
  createBrowserHistory,
  createMemoryHistory,
} from "mobx-route";

routeConfig.update({
  history: createHashHistory(),
  history: createBrowserHistory(),
  history: createMemoryHistory(),
})

queryParams

This is instance of the QueryParams class from mobx-location-history package
This class is also can be exported from mobx-route package.

baseUrl

Specifies the base URL for all routes. This is used as a prefix for every route path and helps in forming complete URLs relative to this base. It's particularly useful when your application is not hosted at the root of a domain and you need consistent URL structures.

Released under the MIT License.