title: Next-Auth Signout within jwt callback
body: <p>If a user is signed into the app between app upgrades, then I want to sign out the user the next time they visit.</p>
  <p>I am pulling the version in from the <code>package.json</code> and storing it in the jwt/session to have for comparison of which version the user authenticated from and what version is now running.</p>
  <pre><code>// pages/api/auth/[nextauth].ts
  const version = require('../../../package.json').version
  import NextAuth from 'next-auth'
  import { signOut } from 'next-auth/react'
  
  export default NextAuth({
    providers: [ /*...*/ ],
    session: { strategy: 'jwt' },
    callbacks: {
      async jwt(props) {
        const { token, user, account } = props
        const isSignIn = user?.username ? true :false
        if(isSignIn) {
          token.version = version
          // ...
        }
        if (token?.version !== version) {
          await signOut()
          return {}
        }
        return token
      },
      // ...
    }
  })
  </code></pre>
  <p>This works, but it is throwing an error</p>
  <pre><code>https://next-auth.js.org/errors#jwt_session_error window is not defined {
    message: 'window is not defined',
    stack: ...
    name: 'ReferenceError
  }
  </code></pre>
  <p>I know the error is throwing because I am calling the <code>signOut</code> function on the server side when it is meant to be a browser side function hence the error for <code>window</code> is not defined.</p>
  <p>How else can I call the <code>signOut</code> function without it trying to use the browser side call including the reference to <code>window</code>?</p>