{"record":{"id":"fd583b5d45204516","repo":"sveltejs/kit","slug":"id-has-no-page-so-there-is-no-code-to-pre","errorCode":null,"errorMessage":"'${id}' has no `+page`, so there is no code to preload. If you meant to warm up an endpoint, request it with `fetch` instead.","messagePattern":"'(.+?)' has no `\\+page`, so there is no code to preload\\. If you meant to warm up an endpoint, request it with `fetch` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/client/client.js","lineNumber":2869,"sourceCode":" * Returns a Promise that resolves when the modules have been imported.\n *\n * @param {import('$app/types').RouteId} id\n * @returns {Promise<void>}\n */\nexport async function preloadCode(id) {\n\tif (DEV && id[0] !== '/') {\n\t\tthrow new Error(\n\t\t\t`argument passed to preloadCode must be a route ID (i.e. \"/blog/[slug]\" rather than \"blog/[slug]\")`\n\t\t);\n\t}\n\n\tconst route = __SVELTEKIT_CLIENT_ROUTING__\n\t\t? routes.find((r) => r.id === id)\n\t\t: (route_id_cache.get(id) ?? (await load_route_by_id(id)));\n\n\tif (route === ENDPOINT_ONLY) {\n\t\tif (DEV) {\n\t\t\tconsole.warn(\n\t\t\t\t`'${id}' has no \\`+page\\`, so there is no code to preload. If you meant to warm up an ` +\n\t\t\t\t\t`endpoint, request it with \\`fetch\\` instead.`\n\t\t\t);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (!route) {\n\t\tif (DEV) {\n\t\t\t// warn rather than throw, since under client routing an endpoint-only route id is\n\t\t\t// indistinguishable from a typo — the client manifest only contains routes with a `+page`\n\t\t\tlet message = `'${id}' did not match any route`;\n\n\t\t\tif (__SVELTEKIT_CLIENT_ROUTING__) {\n\t\t\t\tmessage += ` (note that routes without a \\`+page\\` have no code to preload)`;\n\n\t\t\t\t// the most common migration mistake is passing a pathname, which used to work","sourceCodeStart":2851,"sourceCodeEnd":2887,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/client/client.js#L2851-L2887","documentation":"`preloadData()`/`preloadCode()` take route IDs, not URL pathnames. If the given ID resolves to an endpoint-only route (no `+page` file), there is no client code to preload, so SvelteKit warns and returns without loading anything, suggesting `fetch` for warming up endpoints.","triggerScenarios":"Calling `preloadData('/api/...')` or `preloadCode()` with the ID of a `+server.js`-only route in DEV; the resolver in packages/kit/src/runtime/client/client.js finds the route, sees `route === ENDPOINT_ONLY`, and warns.","commonSituations":"Preloading API endpoints by mistake assuming preload performs a request; passing pathname strings instead of route IDs after refactoring routes.","solutions":["Use `fetch('/api/...')` to warm up endpoint-only routes instead of preloadData/preloadCode","Only preload route IDs that have a `+page` component","Add a route with a `+page` file if client-side preloading is actually desired"],"exampleFix":"// before\nawait preloadData('/api/data');\n// after\nawait fetch('/api/data');","handlingStrategy":"validation","validationCode":"// only preload routes that have a +page\nconst isEndpointOnly = (id) => id.includes('+server') && !id.includes('+page');\nif (isEndpointOnly(id)) { await fetch(resolveRoute(id)); } else { await preloadData(id); }","typeGuard":"function hasPage(id) { return typeof id === 'string' && id.includes('+page'); }","tryCatchPattern":null,"preventionTips":["Remember preload targets client code, not endpoints — use fetch for APIs","Route IDs include node files like `/x/+page@svelte`, not bare pathnames"],"tags":["preloading","routing","client-side"],"backgroundTag":"invalid-route-id-preload","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}