Recently I started a project in React, using NextJS. I've learned that in this tool, each file in 'pages' folder is a route in the site. But it makes me wonder... is there any way to configure this, so I can have multiple files inside 'pages' folder without showing them when I deploy the app? If so, how can I do it?
Thanks in advance
Recently I started a project in React, using NextJS. I've learned that in this tool, each file in 'pages' folder is a route in the site. But it makes me wonder... is there any way to configure this, so I can have multiple files inside 'pages' folder without showing them when I deploy the app? If so, how can I do it?
Thanks in advance
Share Improve this question asked Sep 15, 2022 at 17:20 Andrés F Ariza CalderónAndrés F Ariza Calderón 2353 gold badges9 silver badges19 bronze badges 2- did you mean dynamic routes ? nextjs/docs/routing/dynamic-routes – norbekoff Commented Sep 15, 2022 at 17:24
- in general, it can be dinamic or static routes – Andrés F Ariza Calderón Commented Sep 15, 2022 at 21:19
2 Answers
Reset to default 7You should not keep non routes/pages related files inside pages folder. All non explicitly pages related files should be formed as ponents or other services and placed to relevant folder like ponents/MyComponent/... or services/... and etc.
If you need temporarily hide some page you can add "#" prefix to the name like #myPage.tsx - it will make it unavailable.
In the way you want to hide it it is impossible If you want to create protected routes for some users or for authenticated well this is different thing
dynamic routes could be the solution but the file/s will be still visible