Skip to content

Commit 035086b

Browse files
authored
Merge pull request #384 from ixartz/next-intl4
Upgrade to next-intl 4
2 parents 30d821b + b41e7fd commit 035086b

File tree

20 files changed

+134
-142
lines changed

20 files changed

+134
-142
lines changed

.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# Clerk authentication
77
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_cmVsYXhlZC10dXJrZXktNjcuY2xlcmsuYWNjb3VudHMuZGV2JA
88

9-
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
10-
119
# Sentry
1210
# Disable Sentry warning with TurboPack
1311
SENTRY_SUPPRESS_TURBOPACK_WARNING=1

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// useRouter should be imported from `next/navigation` instead of `next/router`
1313
"next/router",
1414
// give priority for Link to next/link instead of lucide-react
15-
"lucide-react"
15+
"lucide-react",
16+
// Not used in the project and conflicts with `use()` from React
17+
"chai"
1618
],
1719
"typescript.preferences.preferTypeOnlyAutoImports": true, // Prefer type-only imports
1820

next.config.ts

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,69 @@
1+
import type { NextConfig } from 'next';
12
import withBundleAnalyzer from '@next/bundle-analyzer';
23
import { withSentryConfig } from '@sentry/nextjs';
34
import createNextIntlPlugin from 'next-intl/plugin';
45
import './src/libs/Env';
56

6-
const withNextIntl = createNextIntlPlugin('./src/libs/i18n.ts');
7+
// Define the base Next.js configuration
8+
let nextConfig: NextConfig = {
9+
eslint: {
10+
dirs: ['.'],
11+
},
12+
poweredByHeader: false,
13+
reactStrictMode: true,
14+
serverExternalPackages: ['@electric-sql/pglite'],
15+
};
716

8-
const bundleAnalyzer = withBundleAnalyzer({
9-
enabled: process.env.ANALYZE === 'true',
10-
});
17+
// Initialize the Next-Intl plugin
18+
nextConfig = createNextIntlPlugin('./src/libs/i18n.ts')(nextConfig);
1119

12-
/** @type {import('next').NextConfig} */
13-
export default withSentryConfig(
14-
bundleAnalyzer(
15-
withNextIntl({
16-
eslint: {
17-
dirs: ['.'],
18-
},
19-
poweredByHeader: false,
20-
reactStrictMode: true,
21-
serverExternalPackages: ['@electric-sql/pglite'],
22-
}),
23-
),
24-
{
25-
// For all available options, see:
26-
// https://github.com/getsentry/sentry-webpack-plugin#options
27-
// FIXME: Add your Sentry organization and project names
28-
org: 'nextjs-boilerplate-org',
29-
project: 'nextjs-boilerplate',
20+
// Conditionally enable bundle analysis
21+
if (process.env.ANALYZE === 'true') {
22+
nextConfig = withBundleAnalyzer()(nextConfig);
23+
}
3024

31-
// Only print logs for uploading source maps in CI
32-
silent: !process.env.CI,
25+
// Sentry configuration
26+
const sentryOptions = {
27+
// For all available options, see:
28+
// https://github.com/getsentry/sentry-webpack-plugin#options
29+
// FIXME: Add your Sentry organization and project names
30+
org: 'nextjs-boilerplate-org',
31+
project: 'nextjs-boilerplate',
3332

34-
// For all available options, see:
35-
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
33+
// Only print logs for uploading source maps in CI
34+
silent: !process.env.CI,
3635

37-
// Upload a larger set of source maps for prettier stack traces (increases build time)
38-
widenClientFileUpload: true,
36+
// For all available options, see:
37+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
3938

40-
// Automatically annotate React components to show their full name in breadcrumbs and session replay
41-
reactComponentAnnotation: {
42-
enabled: true,
43-
},
39+
// Upload a larger set of source maps for prettier stack traces (increases build time)
40+
widenClientFileUpload: true,
4441

45-
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
46-
// This can increase your server load as well as your hosting bill.
47-
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
48-
// side errors will fail.
49-
tunnelRoute: '/monitoring',
42+
// Automatically annotate React components to show their full name in breadcrumbs and session replay
43+
reactComponentAnnotation: {
44+
enabled: true,
45+
},
5046

51-
// Hides source maps from generated client bundles
52-
hideSourceMaps: true,
47+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
48+
// This can increase your server load as well as your hosting bill.
49+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
50+
// side errors will fail.
51+
tunnelRoute: '/monitoring',
5352

54-
// Automatically tree-shake Sentry logger statements to reduce bundle size
55-
disableLogger: true,
53+
// Hides source maps from generated client bundles
54+
hideSourceMaps: true,
5655

57-
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
58-
// See the following for more information:
59-
// https://docs.sentry.io/product/crons/
60-
// https://vercel.com/docs/cron-jobs
61-
automaticVercelMonitors: true,
56+
// Automatically tree-shake Sentry logger statements to reduce bundle size
57+
disableLogger: true,
6258

63-
// Disable Sentry telemetry
64-
telemetry: false,
65-
},
66-
);
59+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
60+
// See the following for more information:
61+
// https://docs.sentry.io/product/crons/
62+
// https://vercel.com/docs/cron-jobs
63+
automaticVercelMonitors: true,
64+
65+
// Disable Sentry telemetry
66+
telemetry: false,
67+
};
68+
69+
export default withSentryConfig(nextConfig, sentryOptions);

package-lock.json

Lines changed: 24 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@t3-oss/env-nextjs": "^0.13.4",
4242
"drizzle-orm": "^0.43.1",
4343
"next": "^15.3.1",
44-
"next-intl": "^3.26.5",
44+
"next-intl": "^4.1.0",
4545
"pg": "^8.15.6",
4646
"pino": "^9.6.0",
4747
"pino-pretty": "^13.0.0",

src/app/[locale]/(auth)/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { routing } from '@/libs/i18nNavigation';
1+
import { routing } from '@/libs/i18nRouting';
22
import { enUS, frFR } from '@clerk/localizations';
33
import { ClerkProvider } from '@clerk/nextjs';
44
import { setRequestLocale } from 'next-intl/server';
@@ -9,6 +9,7 @@ export default async function AuthLayout(props: {
99
}) {
1010
const { locale } = await props.params;
1111
setRequestLocale(locale);
12+
1213
let clerkLocale = enUS;
1314
let signInUrl = '/sign-in';
1415
let signUpUrl = '/sign-up';

src/app/[locale]/(marketing)/about/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getTranslations, setRequestLocale } from 'next-intl/server';
22
import Image from 'next/image';
33

44
type IAboutProps = {
5-
params: Promise<{ slug: string; locale: string }>;
5+
params: Promise<{ locale: string }>;
66
};
77

88
export async function generateMetadata(props: IAboutProps) {

src/app/[locale]/(marketing)/portfolio/[slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { routing } from '@/libs/i18nNavigation';
1+
import { routing } from '@/libs/i18nRouting';
22
import { getTranslations, setRequestLocale } from 'next-intl/server';
33
import Image from 'next/image';
44

src/app/[locale]/layout.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Metadata } from 'next';
22
import { PostHogProvider } from '@/components/analytics/PostHogProvider';
33
import { DemoBadge } from '@/components/DemoBadge';
4-
import { routing } from '@/libs/i18nNavigation';
5-
import { NextIntlClientProvider } from 'next-intl';
6-
import { getMessages, setRequestLocale } from 'next-intl/server';
4+
import { routing } from '@/libs/i18nRouting';
5+
import { hasLocale, NextIntlClientProvider } from 'next-intl';
6+
import { setRequestLocale } from 'next-intl/server';
77
import { notFound } from 'next/navigation';
88
import '@/styles/global.css';
99

@@ -42,25 +42,16 @@ export default async function RootLayout(props: {
4242
}) {
4343
const { locale } = await props.params;
4444

45-
if (!routing.locales.includes(locale)) {
45+
if (!hasLocale(routing.locales, locale)) {
4646
notFound();
4747
}
4848

4949
setRequestLocale(locale);
5050

51-
// Using internationalization in Client Components
52-
const messages = await getMessages();
53-
54-
// The `suppressHydrationWarning` attribute in <body> is used to prevent hydration errors caused by Sentry Overlay,
55-
// which dynamically adds a `style` attribute to the body tag.
56-
5751
return (
5852
<html lang={locale}>
59-
<body suppressHydrationWarning>
60-
<NextIntlClientProvider
61-
locale={locale}
62-
messages={messages}
63-
>
53+
<body>
54+
<NextIntlClientProvider>
6455
<PostHogProvider>
6556
{props.children}
6657
</PostHogProvider>

src/app/global-error.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { routing } from '@/libs/i18nNavigation';
3+
import { routing } from '@/libs/i18nRouting';
44
import * as Sentry from '@sentry/nextjs';
55
import NextError from 'next/error';
66
import { useEffect } from 'react';

0 commit comments

Comments
 (0)