Skip to content

[Bug?]: Meta title and description undefined when preload pages #1881

Description

@multivoltage

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.x2.xtargeting SolidStart 2.x versionsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions