-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
feat: Exploration of ppr
and dynamicIO
#1531
Draft
amannn
wants to merge
35
commits into
v4
Choose a base branch
from
feat/next-future
base: v4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…ply, static messages import
amannn
changed the title
feat:
feat: Exploration of Nov 13, 2024
ppr
, dynamicIO
& friendsppr
, dynamicIO
& friends
# Conflicts: # docs/src/pages/docs/usage/configuration.mdx # docs/src/pages/docs/usage/dates-times.mdx # examples/example-app-router-playground/src/i18n/request.tsx # packages/next-intl/eslint.config.mjs # packages/next-intl/src/server/react-server/getDefaultNow.tsx
amannn
commented
Nov 14, 2024
<Navigation /> | ||
{children} | ||
</NextIntlClientProvider> | ||
<Suspense> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should ideally work without this (probably requires an equivalent of dynamicParams = false
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An exploration of how
next-intl
can adapt better forppr
anddynamicIO
(see #1493).Centralized validation of
[locale]
segment withdynamicParams = false
If params can be read statically, we could use
dynamicParams = false
to return a 404 for unknown locales (see d1a0308).However, it seems like this isn't a good idea to introduce yet:
dynamicParams
is not compatible withdynamicIO
—and maybe never will:However, it seems like Next.js is working on an alternative to
dynamicParams = false
. With this, maybe we'll have a reasonable solution for centralized validation of the[locale]
segment.Usage of
setRequestLocale
Calling
setRequestLocale
within a'use cache'
boundary doesn't seem to work. We need a mechanism from Next.js to read params deeply to get rid of this API.Reading the
locale
param without suspendingCurrently not easily possible, waiting for an alternative to
dynamicParams = false
: vercel/next.js#71927.What did work in my test though is to use
'use cache'
on both the layout and page entry point. This might not fit your application though and furthermore makes it impossible to read request-specific params in components. EDIT: It only works in dev, not when building the app.Another use case to be tested would be mixing a statically known
[locale]
param with a dynamic child page (see https://nextjs.org/blog/our-journey-with-caching#partial).Importing of JSON messages
Dynamic imports currently cause an error: vercel/next.js#72589.
Effect of
use(…)
andawait
For the APIs that
next-intl
offers, these seem to not require a suspense boundary for async data—that's helpful.Effect of client-side hooks on caching
Hooks like
useParams
,useSelectedLayoutSegment
andusePathname
work fine in development but error out during the build when used in a dynamic segment like[locale]
, asking for a suspense boundary or'use cache'
. Not sure what the expected behavior is, but there's definitely an inconsistency here. See vercel/next.js#72756.EDIT: This would probably also require a replacement for
dynamicParams = false
.Conclusion
ppr
anddynamicIO
might work (but requires feat!: Remove default ofnow={new Date()}
fromNextIntlClientProvider
for usage withformat.relativeTime
(preparation fordynamicIO
) #1536)API considerations for
next-intl
to consider in the future:i18n/request.ts
. This way we can avoid hardcoding the[locale]
segment and also don't need to bump the peer dependency aggressively once this API is introduced.getLocale
is called ini18n/request.ts
? Would requireAsyncLocalStorage
./
? This will be possible once reading params deeply is a thing.