{"record":{"id":"3f06f4dae87b63a0","repo":"sveltejs/kit","slug":"asset-path-should-now-be-asset-path-sl","errorCode":null,"errorMessage":"`asset('${path}')` should now be `asset('${path.slice(1)}')`","messagePattern":"`asset\\('(.+?)'\\)` should now be `asset\\('(.+?)'\\)`","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/app/paths/client.js","lineNumber":33,"sourceCode":" * ```svelte\n * <script>\n * \timport { asset } from '$app/paths';\n * </script>\n *\n * <img alt=\"a potato\" src={asset('potato.jpg')} />\n * ```\n * @since 2.26\n *\n * @param {AssetPath} file\n * @returns {string}\n */\nexport function asset(file) {\n\tlet path = /** @type {string} */ (file);\n\n\t// TODO 4.0 remove this\n\tif (path[0] === '/') {\n\t\tif (DEV) {\n\t\t\tconsole.warn(`\\`asset('${path}')\\` should now be \\`asset('${path.slice(1)}')\\``);\n\t\t}\n\n\t\tpath = path.slice(1);\n\t}\n\n\treturn (assets || base) + '/' + path;\n}\n\nconst pathname_prefix = hash_routing ? '#' : '';\n\n/**\n * Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.\n *\n * During server rendering, the base path is relative and depends on the page currently being rendered.\n *\n * @example\n * ```js\n * import { resolve } from '$app/paths';","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/paths/client.js#L15-L51","documentation":"In SvelteKit 2.x the `asset()` helper from `$app/paths` expects a path relative to the assets directory, without a leading slash. Passing `/logo.png` triggers a DEV-mode warning and the leading slash is stripped automatically; the behaviour will be removed in 4.0.","triggerScenarios":"Calling `asset('/foo.png')` (file starting with '/') from client-side code in DEV; the client `asset()` in packages/kit/src/runtime/app/paths/client.js detects `path[0] === '/'` and warns.","commonSituations":"Migrating from SvelteKit 1.x where `asset()` took absolute paths; copy-pasted static asset references like `asset('/favicon.ico')` in components.","solutions":["Remove the leading slash: call `asset('foo.png')` instead of `asset('/foo.png')`","Search the codebase for `asset('` with a leading slash inside the argument and fix each occurrence"],"exampleFix":"// before\nconst url = asset('/images/logo.png');\n// after\nconst url = asset('images/logo.png');","handlingStrategy":"validation","validationCode":"function safeAsset(path) { return asset(path.startsWith('/') ? path.slice(1) : path); }","typeGuard":"function hasLeadingSlash(p) { return typeof p === 'string' && p.startsWith('/'); }","tryCatchPattern":null,"preventionTips":["Never pass absolute paths to `asset()`","Centralize asset URL building in one helper","Grep for `asset('/` during upgrades"],"tags":["deprecation","paths","assets"],"backgroundTag":"deprecated-asset-path-argument","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}