Skip to content
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: Add support for using next-intl in the app folder with Next.js 13 #144

Merged
merged 27 commits into from
Dec 9, 2022

Conversation

amannn
Copy link
Owner

@amannn amannn commented Nov 24, 2022

This PR includes the minimal change that we have to do to be able for next-intl to be used in the app folder.

Features:

  • NextIntlProvider can now be used in the app folder. Note that all components that make use of useTranslations or useIntl still need to be marked with 'use client';. A way to remove this restriction is explored in feat!: Next.js 13 RSC integration #149.
  • Expose a middleware that can be used to set up i18n routing. This is available via import {createIntlMiddleware} from 'next-intl/server';

Pre-release:

npm install [email protected]

CodeSandbox

Fixes #147


What's missing

  1. A way to read the current pathname in the root layout to set the <html lang={…} /> prop correctly (reference).

What's nice to have

  1. Setting arbitrary values like locale directly in the request storage (like cookies()) to be able to use this conveniently everywhere
  2. Being able to use headers() and cookies() in middleware for a unified interface
  3. Setting values with the cookies() API

Potential TODOs

  • Publish [email protected]
  • Generate locales statically This is not called for me during the build, no idea why. Bug?
  • Explore using next-intl in head
  • Tests
  • Domain routing
  • Set html[lang]

@amannn amannn self-assigned this Nov 24, 2022
@vercel
Copy link

vercel bot commented Nov 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
next-intl ✅ Ready (Inspect) Visit Preview Dec 9, 2022 at 7:36PM (UTC)

@amannn amannn changed the title docs: Next.js 13 app folder example feat: Next.js 13 app folder support & example Nov 30, 2022
# Conflicts:
#	packages/next-intl/package.json
@amannn amannn changed the title feat: Next.js 13 app folder support & example feat: Add support for using next-intl in the app folder with Next.js 13 Dec 8, 2022
@amannn amannn marked this pull request as ready for review December 9, 2022 19:35
@amannn amannn merged commit 18c94d6 into main Dec 9, 2022
@amannn amannn deleted the feat/next-13-minimum branch December 9, 2022 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for nextjs v13
1 participant