Next.js
Table of Contents
Quick start#
To build a Next.js application using the Porsche Design
System, follow these steps. This guide is based on the following dependencies:
next@15react@19tailwindcss@4@porsche-design-system/components-react@3
npx create-next-app@latest
✔ What is your project named? "my-app"
✔ Would you like to use TypeScript? "Yes"
✔ Would you like to use ESLint? "Yes"
✔ Would you like to use Tailwind CSS? "Yes"
✔ Would you like your code inside a `src/` directory? "No"
✔ Would you like to use App Router? (recommended) "Yes"
✔ Would you like to use Turbopack for `next dev`? "No"
✔ Would you like to customize the import alias (`@/*` by default)? "No"
You're all set! Start building your own application now.
Integration#

The following examples use the SSR sub-package from @porsche-design-system/components-react/ssr
.
This sub-package is a specialized build of the Porsche Design System components that renders different markup on the
server compared to the browser. While this deviates from traditional SSR/SSG rules (where browser and server markup
should be identical), it's necessary to enable SSR/SSG with web components and Shadow DOM.
The two environments are detected via the process.browser
flag, which is replaced with a boolean value at build time.
In the browser, the components behave like the standard React components from @porsche-design-system/components-react
.
On the server, the behavior differs: Relevant markup and styles are rendered into a Declarative Shadow DOM, which modern
browsers convert to a real Shadow DOM without JavaScript. This handles the initial render efficiently. Once the client
code loads and executes, the Porsche Design System components initialize as usual.
Important: Ensure dead code elimination is enabled for the client build to prevent server-side code from leaking
into the browser bundle.
Step 1
Install the Porsche Design System within your project directory.
npm install @porsche-design-system/components-react
Step 2
Wrap your app with the <PorscheDesignSystemProvider />
.
import { PorscheDesignSystemProvider } from '@porsche-design-system/components-react/ssr';
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>
<PorscheDesignSystemProvider>{children}</PorscheDesignSystemProvider>
</body>
</html>
);
}
Step 3 (recommended)
To boost your web application's performance and minimize issues like FOUC (Flash of Unstyled Content) and FOUT (Flash of
Unstyled Text), you can integrate Partials from the Porsche Design System into the <head>
section of your HTML.
import { PorscheDesignSystemProvider } from '@porsche-design-system/components-react/ssr';
import {
getComponentChunkLinks,
getFontFaceStyles,
getFontLinks,
getIconLinks,
getInitialStyles,
getMetaTagsAndIconLinks,
} from '@porsche-design-system/components-react/partials';
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<head>
{/* necessary for SSR support, injects stylesheet which defines visibility of pre-hydrated PDS components */}
{getInitialStyles({ format: 'jsx' })}
{/* injects stylesheet which defines Porsche Next CSS font-face definition (=> minimize FOUT) */}
{getFontFaceStyles({ format: 'jsx' })}
{/* preloads Porsche Next font (=> minimize FOUT) */}
{getFontLinks({ format: 'jsx' })}
{/* preloads PDS component core chunk from CDN for PDS component hydration (=> improve loading performance) */}
{getComponentChunkLinks({ format: 'jsx' })}
{/* preloads Porsche icons (=> minimize FOUC) */}
{getIconLinks({ format: 'jsx' })}
{/* injects favicon, apple touch icons, android touch icons, etc. */}
{getMetaTagsAndIconLinks({ appTitle: 'Porsche', format: 'jsx' })}
</head>
<body>
<PorscheDesignSystemProvider>{children}</PorscheDesignSystemProvider>
</body>
</html>
);
}
Step 4 (recommended)
Setting up Tailwind CSS with the Porsche Design System
Tailwind CSS Theme allows you to leverage a utility-first CSS framework while maintaining
seamless styling consistency with Porsche's design principles. This integration enables you to use the provided
Patterns and Templates, all written in Tailwind CSS, to build your application quickly and
efficiently.
@import 'tailwindcss';
@import '@porsche-design-system/components-react/tailwindcss';
Step 5
Add a Porsche Design System component (e.g., <PWordmark />
) with some Tailwind CSS styles. Then, run npm run dev
and
verify that the component and styles display correctly.
import { PWordmark } from '@porsche-design-system/components-react/ssr';
export default function Home() {
return (
<>
<div className="grid justify-items-center gap-fluid-md m-static-lg p-fluid-lg bg-surface rounded-lg">
<PWordmark />
<h1 className="prose-display-md">Porsche Design System</h1>
</div>
<div className="…">…</div>
</>
);
}