[Bug?]: Meta title and description undefined when preload pages
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 426
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 11
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
I have a [slug.tsx]. meta title and description render "undefined" when load page directly, but render title correctly when navigate from "list" page to "[slug.tsx]" page with an anchor.
// [slug.tsx]
const getPillQuery = query(async (slug: string) => {
"use server";
return getPillBySlug(slug);
}, "pill");
export const route = {
load: ({ params }) => {
void getPillBySlug(params.slug);
},
} satisfies RouteDefinition;
export default function PillPage(props: RouteSectionProps) {
const pill = createAsync(() => getPillQuery(props.params.slug))
return (
<main>
<Title>{pill()?.title}</Title>
todo
</main>
);
}
and app.config.ts
export default defineConfig({
server: {
prerender: {
routes: ["/", "/pills"],
},
hooks: {
async "prerender:routes"(routes) {
const pills = await getPills();
pills.forEach(({ id, slug }) => routes.add(`/pills/${slug}`));
},
},
},
});
Expected behavior 🤔
I have a list of "pills" and want to generate a build time N pages. Each page should have right info.
Maybe I do in a wrong way
Context 🔦
No response
Your environment 🌎
- node 22
- using npm
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the direct load and client navigation difference in [slug.tsx], then trace the route load and createAsync usage alongside the prerender:routes hook in app.config.ts. Check how the generated /pills/${slug} pages obtain their title and description; done means direct loads and navigations render the same metadata for every prerendered page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100