DioxusLabs/dioxus · error

index route does not exist: {err} use MemoryHistory::with_i

Error message

index route does not exist:
{err}
 use MemoryHistory::with_initial_path to set a custom path

What it means

MemoryHistory tried to resolve the index route ("/") but the user's Routable enum has no route matching that path. The default constructor parses "/"; when the app defines no index route, construction fails and suggests with_initial_path to supply a valid starting route.

Source

Thrown at packages/history/src/memory.rs:48

    /// # #[component]
    /// # fn OtherPage() -> Element { VNode::empty() }
    /// #[derive(Clone, Routable, Debug, PartialEq)]
    /// enum Route {
    ///     #[route("/")]
    ///     Index {},
    ///     #[route("/some-other-page")]
    ///     OtherPage {},
    /// }
    ///
    /// let mut history = dioxus_history::MemoryHistory::with_initial_path(Route::Index {});
    /// assert_eq!(history.current_route(), Route::Index {}.to_string());
    /// assert_eq!(history.can_go_back(), false);
    /// ```
    pub fn with_initial_path(path: impl ToString) -> Self {
        Self {
            state: MemoryHistoryState{
                current: path.to_string().parse().unwrap_or_else(|err| {
                    panic!("index route does not exist:\n{err}\n use MemoryHistory::with_initial_path to set a custom path")
                }),
                history: Vec::new(),
                future: Vec::new(),
            }.into(),
            base_path: None,
        }
    }

    /// Set the base path for the history. All routes will be prefixed with this path when rendered.
    ///
    /// ```rust
    /// # use dioxus_history::*;
    /// let mut history = MemoryHistory::default().with_prefix("/my-app");
    ///
    /// // The base path is set to "/my-app"
    /// assert_eq!(history.current_prefix(), Some("/my-app".to_string()));
    /// ```
    pub fn with_prefix(mut self, prefix: impl ToString) -> Self {

View on GitHub (pinned to 24f6a829df)

Solutions

  1. The initial path matches no index route. Use MemoryHistory::with_initial_path to set an initial path that exists in the Routable enum.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/history/src/memory.rs:48 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/611b97352807918d. Report an issue: GitHub.