Have a next13 project and page.js isn't working but index.js is. Is there config i'm missing?
Unanswered
Reddish Egret posted this in #help-forum
Reddish EgretOP
Just want to understand that really, thinking when page.js works layout.js in the same folder should get inherited too? At the moment its not.
14 Replies
@Reddish Egret Just want to understand that really, thinking when page.js works layout.js in the same folder should get inherited too? At the moment its not.
there is no index.js in the app router, although it works in the pages router
@joulev there is no index.js in the app router, although it works in the pages router
Reddish EgretOP
This is in the pages folder.
@Reddish Egret This is in the pages folder.
yes then index.js that is
pages/page.js will lead to /page route not /@joulev yes then index.js that is
Reddish EgretOP
Really why would anyone want their pages proxied through /pages rather than /?
@Reddish Egret Really why would anyone want their pages proxied through /pages rather than /?
you are misunderstanding –
page.js syntax (along with layout.js, loading.js and so on) is only applicable in the app router, app/, which is different from the pages router (pages/)the way of doing routing in different routers is different
Reddish EgretOP
Yes I am. But I read the next docs and thought I followed the diagrams.
So if I use app folder instead I can do this stuff and pages is the old way prior to 13 upgrade?
either you do
app/path/to/route/page.js or you do pages/path/to/route.js to render /path/to/route@joulev either you do `app/path/to/route/page.js` or you do `pages/path/to/route.js` to render `/path/to/route`
Reddish EgretOP
Can you do something like create an app/layout.js and pop a useContext in it and then apply that to select pages in /pages/etc/? Is that kind of thing supported?
@Reddish Egret Can you do something like create an app/layout.js and pop a useContext in it and then apply that to select pages in /pages/etc/? Is that kind of thing supported?
No. App router and pages router are two different react apps
Reddish EgretOP
Okay, super confused just went with wrapping useContext in _app rather than trying to focus on just the /item/ pages in the end. Thanks for your help.