-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App Router Support #383
Comments
App router is now stable https://nextjs.org/blog/next-13-4 |
Update: we are feature complete for App Router. Next steps:
|
Hey there, seeing no update here for a while, is this going anywhere? I'm interested in being able to use the app router with headstartwp. |
The work itself to make HeadstartWP compatible with App Router is complete. There has been quite a few releases to the You can try it out today using the latest |
Summary
This is the main issue for implementing App Router Support and it will describe the current plan.
What needs to happen
Goals
Implementation Brief
The sections below describes the technical plan at a high-level.
Data Fetching
useFetch
that isn't a hook but an async function:fetchStrategy()
fetchPosts
,fetchPosts
,fetchSearch
,fetchSearchNative
that uses thefetchStrategy
function that executes the strategy.fetch*
functions should accept the params from a pre-defined catch-all argument (e.g [...path].ts) so that it automatically extract params from the URL. However, this will need to be passed explicitly instead of automagically as in the pages router.@headstartwp/core
export.By keeping the current Fetch Strategies as is we can reuse all of the logic between Pages Router, App Router and Client-side data-fetching.
We can look for opportunities to streamline fetch strategies. However, I don't foresee a need for utilizing the "fetch strategy way" of doing things for custom/third-party endpoints. In the Pages Router the fetch strategy was useful for allowing "isomorphic data-fetching", with the app router most of data fetching will be server side so there's no need for that. Therefore we should treat "fetch strategies" as an internal concept.
SEO Handling
With the App Router we mostly just need a utility function to extract the yoastSeo metadata out of the API.
BlocksRenderer
This is essentially completed in the PoC. The main thing to note is that it will no longer automatically load the config from the App's Context Provider since that is not avaliable in Server Components, instead, the config should be passed to it if necessary.
The example below show what will be possible using the BlocksRender and Server Components. Any custom block can fetch additional data right in the component, for instance, it can fetch a list of posts from the blocks attribute ids.
With Suspense & Streaming we can make it so that it doesn't block rendering the rest of the page and with Partial Pre-rendering we can still ship a static shell of the page while the rest of the blocks finish loading.
We currently have a few hooks that gets the attribute we should probably convert those into regular functions since they don't need to be hooks anyway.
Additionally we could look into having
BlocksRenderer
automatically passattributes
as props to avoid needing block components to read the attributes themselves fromdomNode
.Config Loading
Need to look into the better way to load the config with the App Router. We could keep injecitng it at build time or we could simply provide an async function that would support loading the config in server components.
This is important because of how we support multisite today.
Multisite
Multisite will work mostly the same way.
Next.js Handlers
We'd want to move the core logic of
revalidateHandler
andpreviewHandle
to a separate function to make it able to work with the Next.js specific Request/Response objects of the Pages rotuer and the Web-compatible Request/Response objects of the App Router.The
previewHandle
will need some rework though as the way draft mode works is a bit different and doesn't supportpreviewData
object which we currently need.Internationalization and Polylang Support
We'll need to add this to middleware.
https://nextjs.org/docs/app/building-your-application/routing/internationalization
The text was updated successfully, but these errors were encountered: