Next.js Discord

Discord Forum

Link

Unanswered
Swallow-tailed Kite posted this in #help-forum
Open in Discord
Swallow-tailed KiteOP
If I put the component under the pages folder, vercele does not load. When it's in the same directory as Pages, I can load it. But this time I can't use Link in component

<Link href={/component/detail/list/detail?id=${item._id}} style={{ textDecoration: 'none' }}>

4 Replies

Components aren't routes.
When you place a component in pages directory it is being interpreted as a route, in appdir only the page file is the route. there are some special files like layout and route besides that, everything are components and therefore you absolutely can`t use them as routes.
@pedromendes Components aren't routes. When you place a component in pages directory it is being interpreted as a route, in appdir only the `page` file is the route. there are some special files like `layout` and `route` besides that, everything are components and therefore you absolutely can`t use them as routes.
Swallow-tailed KiteOP
I can't use it exactly as you said. What I did was this. I had multiple pages. The working principle of these pages is the same. I was using API on these pages, I was sending data from this API to a list in components. In that list, when the user clicked on any item, the detail page would open. In local, this is working, but I am aware that it is a wrong method. How do you think I can solve this problem?
@pedromendes Components aren't routes. When you place a component in pages directory it is being interpreted as a route, in appdir only the `page` file is the route. there are some special files like `layout` and `route` besides that, everything are components and therefore you absolutely can`t use them as routes.
Swallow-tailed KiteOP
I used Link in the component, but I moved the detail component to the pages. Thanks to this, I was able to download vercel. I don't think this method is very accurate but it worked for now. Thank you for your answer.