Skip to main 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(BACKEND_URL, context)

return {
props: {
nhostSession
}
}
}

Parameters


backendUrl required string

URL of your Nhost application


context required GetServerSidePropsContext<ParsedUrlQuery, PreviewData>

Next.js context


Examples

Using an arrow function

export const getServerSideProps: GetServerSideProps = async (context) => {
const nhostSession = await getNhostSession(BACKEND_URL, context)

return {
props: {
nhostSession
}
}
}

Using a regular function

export async function getServerSideProps(context: GetServerSidePropsContext) {
// or NextPageContext
const nhostSession = await getNhostSession(BACKEND_URL, context)

return {
props: {
nhostSession
}
}
}