Skip to content

Commit

Permalink
docs: Remove mentions of createServerContext
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Oct 1, 2023
1 parent 0afcc2c commit ab22c29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/pages/blog/next-intl-3-0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ If you want to stay on the `as-needed` strategy, you can [configure this option]

With the newly introduced Server Components support comes a temporary workaround for static rendering.

If you call APIs like `useTranslations` in a Server Component, by default, the hook will opt the page into dynamic rendering. This is a temporary limitation that we aim to remove once [`createServerContext`](https://react.dev/blog/2023/05/03/react-canaries#announcing-breaking-changes-and-new-features-early) is supported in Next.js, but as a stopgap solution, we've added the [`unstable_setRequestLocale`](https://next-intl-docs-git-feat-next-13-rsc-next-intl.vercel.app/docs/getting-started/app-router-server-components#static-rendering) API so that you can keep your pages fully static.
If you call APIs like `useTranslations` in a Server Component, by default, the hook will opt the page into dynamic rendering. This is a limitation that we aim to remove in the future, but as a stopgap solution, we've added the [`unstable_setRequestLocale`](https://next-intl-docs-git-feat-next-13-rsc-next-intl.vercel.app/docs/getting-started/app-router-server-components#static-rendering) API so that you can keep your pages fully static.

Note that if you're using `next-intl` exclusively in Client Components, this doesn't apply to your app and static rendering will continue to work as it did before.

Expand Down
13 changes: 5 additions & 8 deletions docs/pages/docs/getting-started/app-router-server-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import Steps from 'components/Steps';

Next.js 13 introduces support for [React Server Components](https://nextjs.org/docs/getting-started/react-essentials) with the App Router and unlocks [many benefits](/docs/environments/server-client-components) when handling internationalization entirely on the server side. `next-intl` is adopting the new capabilities and is currently offering a preview version to early adopters, who are already building apps with Server Components.

<Callout type="warning">
Support for React Server Components is currently available as a release candidate. Please use it at
your own risk, knowing that you may have to migrate upon a stable release.
<Callout>
This page covers a getting started guide for the React Server Components beta that was running over the last couple of months. It's recommended to try out the [next-intl 3.0 release candidate](/blog/next-intl-3-0) if you'd like to use `next-intl` in Server Components.
</Callout>

## Current version

```
npm install [email protected]rc.2
npm install [email protected]beta.19
```

This version was tested with `[email protected]`.
Expand Down Expand Up @@ -190,9 +189,7 @@ That's all it takes! Now you can internationalize your apps on the server side.

## Static rendering

By using APIs like `useTranslations` from `next-intl` in Server Components, your pages will currently opt into dynamic rendering. This is a limitation that will eventually be lifted once [`createServerContext`](https://react.dev/blog/2023/05/03/react-canaries#announcing-breaking-changes-and-new-features-early) is available and integrated in Next.js.

As a stopgap solution, `next-intl` provides a temporary API that can be used to enable static rendering:
By using APIs like `useTranslations` from `next-intl` in Server Components, your pages will currently opt into dynamic rendering. This is a limitation that we aim to remove in the future, but as a stopgap solution, `next-intl` provides a temporary API that can be used to enable static rendering:

<Steps>

Expand Down Expand Up @@ -250,7 +247,7 @@ export default async function IndexPage({

**What does "unstable" mean?**

`unstable_setRequestLocale` is meant to be used as a stopgap solution and will eventually be replaced by an API that's based on `createServerContext`. When that time comes, you'll get a deprecation notice in a minor version and the API will be removed as part of a major version.
`unstable_setRequestLocale` is meant to be used as a stopgap solution and we aim to remove it in the future [in case Next.js adds an API to access parts of the URL](https://github.com/facebook/react/pull/27424#issuecomment-1739464985). If that's the case, you'll get a deprecation notice in a minor version and the API will be removed as part of a major version.

Note that Next.js can render layouts and pages indepently. This means that e.g. when you navigate from `/settings/profile` to `/settings/privacy`, the `/settings` segment might not re-render as part of the request. Due to this, it's important that `unstable_setRequestLocale` is called not only in the parent `settings/layout.tsx`, but also in the individual pages `profile/page.tsx` and `privacy/page.tsx`.

Expand Down

2 comments on commit ab22c29

@vercel
Copy link

@vercel vercel bot commented on ab22c29 Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-intl-example-next-13 – ./examples/example-next-13

next-intl-example-next-13.vercel.app
next-intl-example-next-13-git-main-next-intl.vercel.app
next-intl-example-next-13-next-intl.vercel.app

@vercel
Copy link

@vercel vercel bot commented on ab22c29 Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-intl-docs – ./docs

next-intl-docs.vercel.app
next-intl-docs-next-intl.vercel.app
next-intl-docs-git-main-next-intl.vercel.app

Please sign in to comment.