score:56

Accepted answer

you should move your components outside the pages folder. pages/ should only be used for page components as next.js routing is based on its structure.

next.js has a file-system based router built on the concept of pages.

when a file is added to the pages directory it's automatically available as a route.


even though the above is the default behaviour, you can configure your next.js app to include non-page files in the pages directory.

to do so, you can modify the pageextensions entry in the next.config.js file as shown below. then rename your page components to have a file extension that includes .page (_document.page.js, _app.page.js, index.page.js, etc).

module.exports = {
    pageextensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js']
}

with this configuration, next.js will ignore any file that doesn't contain .page for the purpose of building pages/api routes and routing.

score:0

it seems to be not declared default export keyword in context component. try it as follow:

const  context = ()=>{
  ...
}
export default context

Related Query

More Query from same tag