@djangocfg/nextjs 2.1.164 → 2.1.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -183,12 +183,18 @@ See [PWA.md](./PWA.md) for complete guide.
183
183
 
184
184
  Full next-intl integration for multilingual Next.js apps.
185
185
 
186
+ > **Important:** Use subpath imports to avoid React Context issues in server components:
187
+ > - `@djangocfg/nextjs/i18n` - Types only
188
+ > - `@djangocfg/nextjs/i18n/routing` - `routing`, `createRouting`, `generateLocaleParams`
189
+ > - `@djangocfg/nextjs/i18n/client` - `I18nProvider`, hooks
190
+ > - `@djangocfg/nextjs/i18n/components` - `LocaleSwitcher`
191
+
186
192
  #### 1. Create middleware (proxy.ts)
187
193
 
188
194
  ```tsx
189
195
  // proxy.ts (or middleware.ts)
190
196
  import createMiddleware from 'next-intl/middleware';
191
- import { routing } from '@djangocfg/nextjs/i18n';
197
+ import { routing } from '@djangocfg/nextjs/i18n/routing';
192
198
 
193
199
  export default createMiddleware(routing);
194
200
 
@@ -202,7 +208,8 @@ export const config = {
202
208
  ```tsx
203
209
  // i18n/request.ts
204
210
  import { getRequestConfig } from 'next-intl/server';
205
- import { en, ru, ko, mergeTranslations } from '@djangocfg/i18n';
211
+ import { en, ru, ko } from '@djangocfg/i18n/locales';
212
+ import { mergeTranslations } from '@djangocfg/i18n/utils';
206
213
 
207
214
  const locales = {
208
215
  en: mergeTranslations(en, { app: appEn }),
@@ -226,8 +233,13 @@ export default getRequestConfig(async ({ requestLocale }) => {
226
233
 
227
234
  ```tsx
228
235
  // app/[locale]/layout.tsx
229
- import { I18nProvider, routing } from '@djangocfg/nextjs/i18n';
230
236
  import { getMessages } from 'next-intl/server';
237
+ import { I18nProvider } from '@djangocfg/nextjs/i18n/client';
238
+ import { routing, generateLocaleParams } from '@djangocfg/nextjs/i18n/routing';
239
+
240
+ export function generateStaticParams() {
241
+ return generateLocaleParams();
242
+ }
231
243
 
232
244
  export default async function LocaleLayout({ children, params }) {
233
245
  const { locale } = await params;
@@ -420,10 +432,13 @@ import { RedirectPage } from '@djangocfg/layouts/components/RedirectPage';
420
432
  | Path | Description |
421
433
  |------|-------------|
422
434
  | `@djangocfg/nextjs` | Main exports (all modules) |
423
- | `@djangocfg/nextjs/i18n` | i18n routing, provider, utilities |
435
+ | `@djangocfg/nextjs/i18n` | **Types only** (safe for server components) |
436
+ | `@djangocfg/nextjs/i18n/routing` | `routing`, `createRouting`, `generateLocaleParams` |
437
+ | `@djangocfg/nextjs/i18n/client` | `I18nProvider`, hooks (`'use client'`) |
424
438
  | `@djangocfg/nextjs/i18n/server` | Server-side i18n utilities |
425
- | `@djangocfg/nextjs/i18n/client` | Client-side i18n hooks |
426
- | `@djangocfg/nextjs/i18n/components` | LocaleSwitcher and i18n components |
439
+ | `@djangocfg/nextjs/i18n/components` | `LocaleSwitcher` (`'use client'`) |
440
+ | `@djangocfg/nextjs/i18n/proxy` | `createProxy` for middleware |
441
+ | `@djangocfg/nextjs/i18n/navigation` | `Link`, `redirect`, `usePathname`, `useRouter` |
427
442
  | `@djangocfg/nextjs/ai` | AI documentation search and MCP config |
428
443
  | `@djangocfg/nextjs/config` | Base Next.js configuration factory |
429
444
  | `@djangocfg/nextjs/pwa` | PWA client utilities (service worker registration) |
@@ -464,12 +479,14 @@ createBaseNextConfig({
464
479
 
465
480
  ### i18n
466
481
 
482
+ > **Subpath imports required** - see table below for correct import paths.
483
+
467
484
  #### `routing`
468
485
 
469
486
  Default routing configuration with locales `['en', 'ru', 'ko']` and default locale `'en'`.
470
487
 
471
488
  ```tsx
472
- import { routing } from '@djangocfg/nextjs/i18n';
489
+ import { routing } from '@djangocfg/nextjs/i18n/routing';
473
490
 
474
491
  routing.locales // ['en', 'ru', 'ko']
475
492
  routing.defaultLocale // 'en'
@@ -480,7 +497,7 @@ routing.defaultLocale // 'en'
480
497
  Create custom routing configuration.
481
498
 
482
499
  ```tsx
483
- import { createRouting } from '@djangocfg/nextjs/i18n';
500
+ import { createRouting } from '@djangocfg/nextjs/i18n/routing';
484
501
 
485
502
  const routing = createRouting({
486
503
  locales: ['en', 'de', 'fr'],
@@ -491,10 +508,10 @@ const routing = createRouting({
491
508
 
492
509
  #### `I18nProvider`
493
510
 
494
- Provider component for next-intl integration.
511
+ Provider component for next-intl integration (client component).
495
512
 
496
513
  ```tsx
497
- import { I18nProvider } from '@djangocfg/nextjs/i18n';
514
+ import { I18nProvider } from '@djangocfg/nextjs/i18n/client';
498
515
 
499
516
  <I18nProvider locale="en" messages={messages}>
500
517
  {children}
@@ -14,7 +14,7 @@ var require_package = __commonJS({
14
14
  "package.json"(exports, module) {
15
15
  module.exports = {
16
16
  name: "@djangocfg/nextjs",
17
- version: "2.1.164",
17
+ version: "2.1.166",
18
18
  description: "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
19
19
  keywords: [
20
20
  "nextjs",