Skip to content

useSvelteKitResolve (HTML)

biome.json
{
"linter": {
"rules": {
"nursery": {
"useSvelteKitResolve": "error"
}
}
}
}

Require internal navigation in SvelteKit apps to use paths built with resolve().

SvelteKit’s resolve() from $app/paths prefixes a route with the app’s base path and checks it against the app’s routes. A hand-written href breaks navigation when the app is served from a sub-path, and lets typos in routes go unnoticed.

Links are accepted when their href is an absolute URL, such as https://svelte.dev or mailto:hello@example.com, a protocol-relative URL such as //cdn.example.com, a fragment such as #top, or when the <a> element has rel="external".

This rule only checks href values it can read statically. Expressions such as href={url} aren’t checked.

<a href="/foo">Click me!</a>
code-block.svelte:1:4 lint/nursery/useSvelteKitResolve ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This link's href isn't built with resolve().

> 1 │ <a href="/foo">Click me!</a>
│ ^^^^^^^^^^^
2 │

ℹ Paths that aren't built with resolve() lack the app's base path, and SvelteKit can't check them against the app's routes.

ℹ Wrap the path in resolve() from $app/paths. If the link leaves the app, add rel="external".

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<a href={"/foo"}>Click me!</a>
code-block.svelte:1:4 lint/nursery/useSvelteKitResolve ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This link's href isn't built with resolve().

> 1 │ <a href={"/foo"}>Click me!</a>
│ ^^^^^^^^^^^^^
2 │

ℹ Paths that aren't built with resolve() lack the app's base path, and SvelteKit can't check them against the app's routes.

ℹ Wrap the path in resolve() from $app/paths. If the link leaves the app, add rel="external".

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<a href="/posts/{id}">Click me!</a>
code-block.svelte:1:4 lint/nursery/useSvelteKitResolve ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This link's href isn't built with resolve().

> 1 │ <a href="/posts/{id}">Click me!</a>
│ ^^^^^^^^^^^^^^^^^^
2 │

ℹ Paths that aren't built with resolve() lack the app's base path, and SvelteKit can't check them against the app's routes.

ℹ Wrap the path in resolve() from $app/paths. If the link leaves the app, add rel="external".

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<a href={resolve("/foo")}>Click me!</a>
<a href="https://svelte.dev">Click me!</a>
<a href="/foo" rel="external">Click me!</a>
<a href="#top">Click me!</a>

Whether to ignore all <a> elements. Default: false.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useSvelteKitResolve": {
"level": "on",
"options": {
"ignoreLinks": true
}
}
}
}
}
}
<a href="/foo">Click me!</a>