Home > Enterprise >  Nextjs how can I hide a route in a project
Nextjs how can I hide a route in a project

Time:09-16

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

CodePudding user response:

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

CodePudding user response:

You should not keep non routes/pages related files inside pages folder. All non explicitly pages related files should be formed as components or other services and placed to relevant folder like components/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.

  • Related