Reputation: 635
According to the documentation docs setting the useFileSystemPublicRoutes configuration option to false prevents routing based on files in /pages directory. But i cant understand what it really does because they dont elaborate much.
I will appreciate it if someone could explain it to me with simple examples of what this config does.
Upvotes: 2
Views: 7133
Reputation: 6603
useFileSystemPublicRoutes
set to false
does only one thing - disables built-in server-side routing.
For example, let's say you have two pages:
/pages/foo.js
/pages/bar.js
By default, upon build Next.js will register two routes:
example.com/foo
example.com/bar
When useFileSystemPublicRoutes
set to false
these two routes won't be created at server side, so a user can't access it by typing example.com/foo
in browser URL bar.
However, client-side navigation still can access these routes if you use next/link
or next/router
.
You don't need to use useFileSystemPublicRoutes
config unless you have a custom server and Next.js routes that were registered based on the pages
directory interfere with it.
Upvotes: 5