-
#3140
102bfbf3283Thanks @aliemir! - - Bumped Next.js to 13- Added support for experimental
appDiroption innext.config.jsto allow for the latest Next.js features.
pagesdirectoryCurrent support for
pagesdirectory has not changed and will continue to work as before. It will be supported as long asNext.jscontinues to support and prompts it as the stable way of working withNext.js.appDiroptionappDiroption is a new experimental feature inNext.jsthat introduces a bunch of new features. It is currently in beta and is not stable. It is not recommended to use it in production. But can be used alongside the currentpagesdirectory support.To use
appDiroption, you need to add it to yournext.config.jsfile.// next.config.js module.exports = { /* ... */ experimental: { appDir: true, }, };
Using
appDirwith refineWe've needed to make some changes to the
@pankod/refine-nextjs-routerto make it work with the current structure of theappdirectory feature. To make sure these do not break the current support forpagesdirectory, we've added a new exports at the sub path@pankod/refine-nextjs-router/appthat can be used with theappDiroption.Note
To make optional catch-all routes to work with the
appdirectory, you need to define them as directories unlike the option of defining them as files withpagesdirectory.You need to use
NextRouteComponentfrom@pankod/refine-nextjs-router/appinstead ofNextRouteComponentfrom@pankod/refine-nextjs-routerwhen usingappDiroption.Inside your
layoutfile, you need to bindparamstorouterProviderto make sure@pankod/refine-nextjs-routercan work properly with the new structure.// app/[[...refine]]/layout.tsx "use client"; import routerProvider from "@pankod/refine-nextjs-router/app"; const Layout = ({ children, params }) => { return ( <Refine routerProvider={routerProvider.apply({ params })} /* ... */ > {children} </Refine> ); };
Warning
Please note that, unlike the
routerProviderfrom the@pankod/refine-nextjs-router,routerProviderfrom@pankod/refine-nextjs-router/appis a function and you need to bindparamsto make it work properly.// app/[[...refine]]/page.tsx "use client"; import { NextRouteComponent } from "@pankod/refine-nextjs-router/app"; export default NextRouteComponent;
Warning
You need to add
"use client";directive to bothlayout.tsxandpage.tsxinsideapp/[[...refine]]directory.Warning
checkAuthenticationdoes not work withappDir. We're aiming to release a substitute for it using middleware but for now its not included in this release. - Added support for experimental
from Hacker News https://ift.tt/DnzFuxl
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.