Skip to content

Commit 1841eaa

Browse files
committed
Enhance Next.js configuration and layout for improved performance and font loading
- Added image formats support (AVIF, WebP) and set minimum cache TTL in next.config.ts. - Enabled compression, disabled the powered by header, and activated React strict mode. - Introduced experimental features for optimized package imports from Radix UI and motion. - Updated layout.tsx to include font display settings and preconnect links for Google Fonts, enhancing loading performance.
1 parent 83b856d commit 1841eaa

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

app/layout.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ import "./globals.css"
1515
const geistSans = Geist({
1616
variable: "--font-geist-sans",
1717
subsets: ["latin"],
18+
display: "swap",
19+
preload: true,
1820
})
1921

2022
const geistMono = Geist_Mono({
2123
variable: "--font-geist-mono",
2224
subsets: ["latin"],
25+
display: "swap",
26+
preload: true,
2327
})
2428

2529
export const metadata: Metadata = {
@@ -85,6 +89,11 @@ export default async function RootLayout({
8589

8690
return (
8791
<html lang="en" suppressHydrationWarning>
92+
<head>
93+
<link rel="dns-prefetch" href="https://fonts.googleapis.com" />
94+
<link rel="preconnect" href="https://fonts.googleapis.com" crossOrigin="anonymous" />
95+
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
96+
</head>
8897
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
8998
<ThemeProvider>
9099
<SidebarProvider defaultOpen={defaultOpen}>

next.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ const nextConfig: NextConfig = {
1616
pathname: "/**",
1717
},
1818
],
19+
formats: ["image/avif", "image/webp"],
20+
minimumCacheTTL: 60,
21+
},
22+
compress: true,
23+
poweredByHeader: false,
24+
reactStrictMode: true,
25+
experimental: {
26+
reactCompiler: true,
27+
optimizePackageImports: [
28+
"@radix-ui/react-alert-dialog",
29+
"@radix-ui/react-avatar",
30+
"@radix-ui/react-collapsible",
31+
"@radix-ui/react-dialog",
32+
"@radix-ui/react-dropdown-menu",
33+
"@radix-ui/react-hover-card",
34+
"@radix-ui/react-popover",
35+
"@radix-ui/react-progress",
36+
"@radix-ui/react-scroll-area",
37+
"@radix-ui/react-select",
38+
"@radix-ui/react-separator",
39+
"@radix-ui/react-slot",
40+
"@radix-ui/react-tooltip",
41+
"motion/react",
42+
],
1943
},
2044
}
2145

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"@types/node": "^24",
6666
"@types/react": "^19",
6767
"@types/react-dom": "^19",
68+
"babel-plugin-react-compiler": "^19.1.0-rc.3",
6869
"eslint": "^9",
6970
"eslint-config-next": "15.5.4",
7071
"prettier": "^3.6.2",

0 commit comments

Comments
 (0)