DioxusLabs/dioxus · error · syn::Error
Routes should start with /. Error found in the route
Error message
Routes should start with /. Error found in the route '{}' What it means
`parse_route_segments` errors when the route string does not begin with '/'. The first split segment must be empty (the leading slash); routes like `"home/:id"` are rejected at compile time and must be written `"/home/:id"`. The offending route is named in the message.
Solutions
- Start the route with `/`, e.g. #[route("/users/:id")].
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/router-macro/src/segment.rs:169 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/44adde71b4a202a7.
Report an issue: GitHub.
Appendix: source
Thrown at packages/router-macro/src/segment.rs:169
};
let (route_string, query) = match route_string.rsplit_once('?') {
Some((route, query)) => (
route,
Some(QuerySegment::parse_from_str(
route_span,
fields.clone(),
query,
)?),
),
None => (route_string, None),
};
let mut iterator = route_string.split('/');
// skip the first empty segment
let first = iterator.next();
if first != Some("") {
return Err(syn::Error::new(
route_span,
format!(
"Routes should start with /. Error found in the route '{}'",
route
),
));
}
while let Some(segment) = iterator.next() {
if let Some(segment) = segment.strip_prefix(':') {
let spread = segment.starts_with("..");
let ident = if spread {
segment[2..].to_string()
} else {
segment.to_string()
};
View on GitHub (pinned to 24f6a829df)