2

I'm testing out the Qwik Javascript framework from Builder IO and I cant find any documentation which points me in the direction of customizing the 404 page.

I am using the qwik-city plugin from Qwik.

Rafael Zasas
  • 891
  • 8
  • 27

3 Answers3

2

Check it. It's about how to render a 404 page. https://qwik.builder.io/qwikcity/routing/error-responses/

Lukas
  • 2,263
  • 1
  • 4
  • 15
  • This works great for dynamic routes but I'm looking for general rotues. Eg user routes to `foo/bar` which doesn't exit, how do I customize the existing 404 layout of the framework? – Rafael Zasas Oct 09 '22 at 01:51
  • 1
    There's an open PR which will fix this https://github.com/BuilderIO/qwik/pull/1636 @RafaelZasas – roman Oct 10 '22 at 13:09
2

I was able to do this by creating a "catch all route" at the root level. Simply create a normal page in src/routes/[...whatever]/index.tsx.

szilagyi.sandor
  • 204
  • 1
  • 6
  • Can you please elaborate on this. What does the "Catch All" component look like? Is there any other configuration steps needed? Why would this be different than any of the other `[...whatever]` routes I already have under `routes/`? – Rafael Zasas Oct 12 '22 at 17:15
  • Here you can find more info about "Catch all routes": https://qwik.builder.io/qwikcity/routing/route-parameters/#catch-all-routes. The key is the "..." in the folder name. It will catch every route that has no exact match. The component itself should be similar to any other page component you use. – szilagyi.sandor Oct 13 '22 at 09:39
  • I believe that is dynamic routing- used for things like `/blog/[blogId]/comments/[commentId]`. Using this at the root would cause any route such as `/home` or `/profile` to be routed to that dynamic route instead of their intended component. I believe they are still in the process of building out the customizable error components. – Rafael Zasas Oct 13 '22 at 16:31
  • Yeah, but if you use that at the root level it will catch all the routes that are not specified. The /home and /profile will still go to your pages, if you have a /home/index.tsx and a /profile/index.tsx. – szilagyi.sandor Oct 15 '22 at 11:43
  • I like this as an interim solution that would work well for `404` routes as the route has not been defined but it seems as though it would't work as well for other error responses like `401`. @roman had pointed out that there is an open PR for this issue, which may be a valid solution for all error routing. – Rafael Zasas Oct 26 '22 at 16:58
2

This has been resolved by the official Qwik team. See This PR for details.

Rafael Zasas
  • 891
  • 8
  • 27