You can do it manually. If you see this: https://s...
# support-questions-legacy
r
You can do it manually. If you see this: https://supertokens.com/docs/thirdpartyemailpassword/nextjs/session-verification/in-ssr The code inside
getServerSideProps
is:
Copy code
js
try {
        // getSession will do session verification for us
        session = await Session.getSession(context.req, context.res)
    } catch (err) {
        if (err.type === Session.Error.TRY_REFRESH_TOKEN) {
            
            // in this case, the session is still valid, only the access token has expired.
            // The refresh token is not sent to this route as it's tied to the /api/auth/session/refresh API paths.
            // So we must send a "signal" to the frontend which will then call the 
            // refresh API and reload the page.

            return { props: { fromSupertokens: 'needs-refresh' } }
            // or return {fromSupertokens: 'needs-refresh'} in case of getInitialProps
        } else if (err.type === Session.Error.UNAUTHORISED) {

            // user is logged out. Since this is for a protected route,
            // we can simple send an empty prop object. Alternatively,
            // you can pass anything else you would like here.
            return { props: {} }
            // or return {} in case of getInitialProps
        } else {
            throw err
        }
    }
So in the block for
err.type === Session.Error.TRY_REFRESH_TOKEN
, instead of doing
return { props: { fromSupertokens: 'needs-refresh' } }
, you can just do whatever else you want?