Skip to content

Commit 0d8298e

Browse files
docs: add section for Next.js (#4823)
1 parent c5c3fca commit 0d8298e

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Footer, TableOfContent } from '@sb/components';
2+
import { Meta } from '@storybook/blocks';
3+
import { SsrLimitations } from './SsrLimitations';
4+
5+
<Meta title="Server Side Rendering" />
6+
7+
<TableOfContent />
8+
9+
# Server Side Rendering
10+
11+
We're happy to announce that starting from **v1.17.0**, UI5 Web Components for React is supporting Server Side Rendering Frameworks like [Next.js](https://nextjs.org/) 🎉.
12+
13+
<SsrLimitations />
14+
15+
<br />
16+
<br />
17+
18+
## Next.js
19+
20+
### Create a new project
21+
22+
The best way to start using UI5 Web Components in Next.js is using one of our [templates](https://sap.github.io/ui5-webcomponents-react/?path=/docs/project-templates--docs).
23+
We have templates available for both the pages and the app router.
24+
25+
### Add to existing project
26+
27+
In case you already have an existing Next.js project and want to add UI5 Web Components for React to it, you first need to follow our [general Getting Started Guide](https://sap.github.io/ui5-webcomponents-react/?path=/docs/getting-started--docs#add-ui5webcomponents-react-to-an-existing-app).
28+
29+
As UI5 Web Components for React is using `react-jss` internally, you need to apply some changes to your `_app` and `_document` file (in case you are using the pages router).
30+
You can copy these changes either from the official [next.js-react-jss example](https://github.com/vercel/next.js/tree/canary/examples/with-react-jss) or from our [pages router template](https://github.com/SAP/ui5-webcomponents-react/tree/main/examples/nextjs-pages).
31+
32+
In case you are already using the app router, you can copy the `react-jss` setup from the `app/CssRegistry.tsx` in our [app router template](https://github.com/SAP/ui5-webcomponents-react/tree/main/examples/nextjs-app). Make sure to add this component to your root layout!
33+
34+
## Other frameworks
35+
36+
Your favorite framework is missing here? Feel free to [edit this page](https://github.com/SAP/ui5-webcomponents-react/blob/main/docs/knowledge-base/ServerSideRendering.mdx) and submit a pull request to get it added!
37+
38+
<Footer />
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from 'react';
2+
import { MessageStrip, MessageStripDesign } from '@ui5/webcomponents-react';
3+
4+
export function SsrLimitations() {
5+
return (
6+
<MessageStrip design={MessageStripDesign.Information} hideCloseButton>
7+
<>
8+
<strong>Known Limitations</strong>
9+
<ul>
10+
<li>
11+
As custom elements need to be defined on the client, UI5 Web Components for React is only rendering the
12+
outer markup of the UI5 Web Component on the server. The rendering of the Web Component is still happening
13+
on the client.
14+
</li>
15+
<li>
16+
The Next.js <code>app</code> directory shows some hydration warnings on the client. These warnings seem not
17+
to affect the runtime.
18+
</li>
19+
</ul>
20+
</>
21+
</MessageStrip>
22+
);
23+
}

tsconfig.spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"**/*.cy.ts",
1616
"**/*.cy.tsx",
1717
"cypress.config.ts",
18+
"docs/knowledge-base/*.tsx",
1819
"docs/knowledgeBaseExamples/*.tsx",
1920
"vite.config.ts"
2021
]

0 commit comments

Comments
 (0)