Ninetailed
Search…
Server Side Rendering
This guide describes the steps you need to follow to use Ninetailed with Server Side Rendering (SSR) in Next.js
You can use Next.js to fetch personalized content from the server and serve a fully updated page via server side rendering.
1
import {
2
PersonalizationProvider,
3
getServerSideProfile,
4
} from '@ninetailed/experience-sdk-nextjs';
5
import { Hero } from './Hero';
6
7
const Page = ({ ninetailed, data }) => {
8
<PersonalizationProvider profile={ninetailed.profile} apiKey={API_KEY}>
9
<Personalize component={Hero} headline={data.headline} variants={data.variants}/>
10
</PersonalizationProvider>
11
}
12
13
export async function getServerSideProps() {
14
const profile = await getServerSideProfile(ctx, {
15
apiKey: API_KEY,
16
});
17
18
const data = await getPageData();
19
20
return { props: { ninetailed: { profile }, data } };
21
}
22
23
export default Page
24
25
Copied!
Last modified 2mo ago
Copy link