# Create a new application by executing:
npx create-next-app@latest
# Follow the installation wizard to set everything up:
✔ 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"
npm install @porsche-design-system/components-react
<PorscheDesignSystemProvider />.// app/layout.tsx
+ import { PorscheDesignSystemProvider } from '@porsche-design-system/components-react/ssr'; // ensure to import from ssr subpackage!
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>
+ <PorscheDesignSystemProvider>{children}</PorscheDesignSystemProvider>
</body>
</html>
);
}
/cn import instead, see
/* app/globals.css */
+ @import '@porsche-design-system/components-react';
lightningcss polyfill for the light-dark() CSS function since it's broken.
// next.config.ts
const nextConfig: NextConfig = {
+ experimental: {
+ useLightningcss: true,
+ // disables light-dark() polyfill of lightningcss which is broken https://github.com/porsche-design-system/porsche-design-system/issues/4257
+ lightningCssFeatures: {
+ exclude: ['light-dark'],
+ },
+ },
};
:defined.hydrated:defined
pseudo-class, scope the style to specific tags instead (e.g., :is(p-button, p-accordion, …):not(:defined,[data-ssr])).
See /* app/globals.css */
@import '@porsche-design-system/components-react';
+ :not(:defined,[data-ssr]) {
+ visibility: hidden;
+ }
<head> section of your HTML to preload fonts, icons, and component chunks.// app/layout.tsx
import { PorscheDesignSystemProvider } from '@porsche-design-system/components-react/ssr'; // ensure to import from ssr subpackage!
+ import {
+ getComponentChunkLinks,
+ getFontLinks,
+ getIconLinks,
+ getMetaTagsAndIconLinks,
+ } from '@porsche-design-system/components-react/partials';
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<head>
+ {/* preloads fonts */}
+ {getFontLinks({ format: 'jsx' })}
+ {/* preloads icons */}
+ {getIconLinks({ format: 'jsx' })}
+ {/* preloads components */}
+ {getComponentChunkLinks({ format: 'jsx' })}
+ {/* injects favicon, apple touch icons, android touch icons, etc. */}
+ {getMetaTagsAndIconLinks({ appTitle: 'Porsche', format: 'jsx' })}
</head>
<body>
<PorscheDesignSystemProvider>{children}</PorscheDesignSystemProvider>
</body>
</html>
);
}
/* app/globals.css */
@import '@porsche-design-system/components-react';
+ @import 'tailwindcss';
+ @import '@porsche-design-system/components-react/tailwindcss';
<PWordmark />) with some Tailwind CSS styles. Then, run npm run dev and
verify that the component and styles display correctly.// app/page.tsx
import { PWordmark } from '@porsche-design-system/components-react/ssr'; // ensure to import from ssr subpackage!
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-heading-4xl">Porsche Design System</h1>
</div>
<div className="…">…</div>
</>
);
}
