Catch all Routes with File-Based Routing — Transcript

Transcript of the free Vue.js lesson Catch all Routes with File-Based Routingwatch the video lesson.

You can also create catch all routes in Unplugin View Router. Essentially, these are routes that will display if no other existing page matches the route that the user visits. What this boils down to is the catch all route is good for 404, not found pages. What does the syntax look like then?

Well, in the root of the pages directory, you can create a file with the square brackets, then three periods, and the word path so this word path is actually a dynamic variable name you could really name it anything you like but the convention is to name it path the important part is that we put the ellipsis or the three dots before it this tells you router this is the catch-all now inside of that file you're typically going to show something to the user that says 404 not found But note here that we have access to the full path on the parameters. So whatever we named the variable here inside the file name, it's now available on the params object, just like the ID parameter was for our normal dynamic params. Over in the browser, if I visit a page that is not handled by a specific route, so in this case, slash no exist, indeed, I get the 404 not film page displaying. path equals no-exist.

path as well.