最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Nextjs how can I hide a route in a project - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 7

You 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

发布评论

评论列表(0)

  1. 暂无评论