https://www.growthbook.io/ logo
#announcements
Title
# announcements
f

fierce-church-81643

12/23/2022, 4:17 PM
Hi there! By any chance, is it possible to use React SDK for SSR in next.js?
f

fresh-football-47124

12/23/2022, 4:17 PM
yes
you can have the growth init and attribute setting in the getServerSideProps()
and use those values of the flags wherever you need
f

fierce-church-81643

12/23/2022, 5:13 PM
Ah I see, how do I pass the SDK output to the render method?
f

fresh-football-47124

12/23/2022, 5:24 PM
The props returned in the getServerSideProps() are passed in to the main page props
like this:
Copy code
export default function About({ message }) {
    return (
        <div>
            <h1>{message}</h1>
        </div>
    );
}
    
export function getServerSideProps() {
    return {
        props: { message: "Welcome to the About Page" },
    };
}
👍 1
f

fierce-church-81643

12/23/2022, 5:32 PM
thx
Merry Christmas
f

fresh-football-47124

12/23/2022, 5:32 PM
no problem, you too
f

fierce-church-81643

01/09/2023, 10:36 AM
@fresh-football-47124 I am still struggling with the SSR integration. You can pass only valid JSON as ServerSideProps. So I assume, that user assignment must be located in the page / components, right?
6 Views