solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

[✨] Feature: Add by default the 404 page of solid or add in the doc how to setup 404 page #322

Closed TheElegantCoding closed 8 months ago

TheElegantCoding commented 8 months ago

Describe the bug

Sorry for posting this as an issue. I can't open a blank issue or a feature request, Solid js router has a lack of 404 page this happens to me a lot, in a project when I go to another URL that is not registered I get a blank page that is not a default one for 404, also this should be documented in the docs, others frameworks like astro, nextjs qwik has 404 page, solid should have one

Your Example Website or App

none

Steps to Reproduce the Bug or Issue

none

Expected behavior

none

Screenshots or Videos

No response

Platform

Additional context

No response

Brendan-csel commented 8 months ago

I think you can always add a "catch-all" route at after all your others. Something like:

<Route path="*" component={() => <div>404 - looks like you're lost</div>} />
ryansolid commented 8 months ago

@Brendan-csel that is correct. A 404 page would just be a catchall and you can add them at any depth of nesting. So you can put 404s in partial layouts etc.

Keep in mind all the frameworks you listed are server-rendered frameworks. It is almost unheard of client routers to provide 404 pages by default. I think it is mostly that server is stuck always haven't to handle the request and needs to send something back. If you look at solidjs/start our metaframework you will see all the examples have built-in 404 pages. But the router itself seeks to be a bit less opinionated.

But yeah we should add something to the Readme.

TheElegantCoding commented 8 months ago

thanks for the response, i will keep the issue open ultil the readme is updated, please also add the "feature template" of github issues for this repo