SolidJSS
SolidJSβ€’10mo agoβ€’
3 replies
Garzec

Need help understanding preload and file conventions

Hello guys,
I started with SolidStart and want to fetch data before rendering the page, So I found preload here https://docs.solidjs.com/solid-start/building-your-application/routing#additional-route-config and started with

import { RouteDefinition } from "@solidjs/router";

export const routeDefinition: RouteDefinition = {
  async preload({ params }) {
    await new Promise((resolve, reject) => setTimeout(resolve, 3000)) // show pending component page
    throw new Error("ERR"); // show error component page
  }
}

export default function Page() {
    return <div>Page</div>;
}


It "somehow" works, the preload function was called. I also created 3 other components in the same directory => notFound.tsx, pending.tsx, error.tsx.
All of those 3 files might need different names, I don't know.

My questions are:
- How do I render a 404 page?
- Is it possible to render a pending page while preloading the data? How?
- How do I render an error page if the preload function throws?
- How do I access the fetched data inside my "success" page?

I wasn't able to find it in the docs and maybe I completely misunderstood the concepts here πŸ™‚ But I know that https://tanstack.com/router handles things this way
Was this page helpful?