{"record":{"id":"e45344749c4c2add","repo":"sveltejs/kit","slug":"only-svelte-files-can-reference-named-layouts-rem","errorCode":null,"errorMessage":"Only Svelte files can reference named layouts. Remove '${match[3] || match[6]}' from ${file} (at ${project_relative})","messagePattern":"Only Svelte files can reference named layouts\\. Remove '(.+?)' from (.+?) \\(at (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/create_manifest_data/index.js","lineNumber":558,"sourceCode":"\t\t}\n\n\t\treturn {\n\t\t\tkind: 'component',\n\t\t\tis_page: !!match[1],\n\t\t\tis_layout: !!match[3],\n\t\t\tis_error: !!match[5],\n\t\t\tuses_layout: match[2] ?? match[4]\n\t\t};\n\t}\n\n\tconst module_extension = module_extensions.find((ext) => file.endsWith(ext));\n\tif (module_extension) {\n\t\tconst name = file.slice(0, -module_extension.length);\n\t\tconst match = module_name_pattern.exec(name);\n\t\tif (!match) {\n\t\t\tthrow new Error(`Files prefixed with + are reserved (saw ${project_relative})`);\n\t\t} else if (match[3] || match[6]) {\n\t\t\tthrow new Error(\n\t\t\t\t// prettier-ignore\n\t\t\t\t`Only Svelte files can reference named layouts. Remove '${match[3] || match[6]}' from ${file} (at ${project_relative})`\n\t\t\t);\n\t\t}\n\n\t\tconst kind = match[1] || match[4] || match[7] ? 'server' : 'universal';\n\n\t\treturn {\n\t\t\tkind,\n\t\t\tis_page: !!match[2],\n\t\t\tis_layout: !!match[5]\n\t\t};\n\t}\n\n\tthrow new Error(`Files and directories prefixed with + are reserved (saw ${project_relative})`);\n}\n\n/**","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/create_manifest_data/index.js#L540-L576","documentation":"Named layout references (the `@group` suffix, e.g. +layout@auth) are only allowed in Svelte files like +layout@group.svelte. When a JS/TS module filename (matched by module_name_pattern) contains an `@` reference (capture groups 3 or 6), sync throws this error because named layouts only make sense for route components, not for server/universal load modules.","triggerScenarios":"Creating files like +page@group.js, +layout@auth.ts, or +page@group.server.js under src/routes — module files with an @named-layout suffix.","commonSituations":"Copying the name of a +layout@group.svelte file when creating its companion load module; misunderstanding that @group applies only to the Svelte component; renaming a component to .ts without removing the @ part.","solutions":["Remove the @group part from the module filename: +page@group.js → +page.js.","Keep the @group reference only on the corresponding Svelte file (+layout@group.svelte).","If you need per-group load logic, place the module alongside the plain route file — group association comes from the directory structure and the .svelte component, not the module."],"exampleFix":"// before\nsrc/routes/(app)/+layout@dashboard.ts\n// after\nsrc/routes/(app)/+layout.ts   (+layout@dashboard.svelte keeps the named layout)","handlingStrategy":"validation","validationCode":"for (const f of routeFiles.filter((f) => f.startsWith('+') && /\\.(js|ts)$/.test(f))) {\n  if (/^\\+(page|layout)@/.test(f)) throw new Error(`@named-layout not allowed on module file: ${f}`);\n}","typeGuard":"function moduleUsesNamedLayout(basename) {\n  return /^\\+(page|layout)@[a-zA-Z0-9_-]*/.test(basename);\n}","tryCatchPattern":"null","preventionTips":["Remember @group applies only to +layout@group.svelte / +page@group.svelte components.","When duplicating a component name for its load module, strip the @ part.","Associate modules with groups via the (group) directory, not the filename."],"tags":["sveltekit","routing","named-layouts","file-naming"],"backgroundTag":"reserved-file-name-conflict","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}