Skip to content

getNhostSession()

Refreshes the access token if there is any and returns the Nhost session.

@returns

Nhost session

export const getServerSideProps: GetServerSideProps = async (context) => {
const nhostSession = await getNhostSession(
{ subdomain: '<project_subdomain>', region: '<project_region>' },
context
)
return {
props: {
nhostSession
}
}
}

params required Partial<Pick<NhostReactClientConstructorParams, “subdomain” | “region” | “authUrl” | “graphqlUrl” | “storageUrl” | “functionsUrl”>>


context required GetServerSidePropsContext<ParsedUrlQuery, PreviewData>

Next.js context


export const getServerSideProps: GetServerSideProps = async (context) => {
const nhostSession = await getNhostSession(
{ subdomain: '<project_subdomain>', region: '<project_region>' },
context
)
return {
props: {
nhostSession
}
}
}
export async function getServerSideProps(context: GetServerSidePropsContext) {
// or NextPageContext
const nhostSession = await getNhostSession(
{ subdomain: '<project_subdomain>', region: '<project_region>' },
context
)
return {
props: {
nhostSession
}
}
}