title: Nuxt 3 use composable in middleware
body: <p>I want to guard a route by checking if the user is logged in, but:</p>
  <ol>
  <li>I can't read the composable value,</li>
  <li>I am unsure if my middleware got the right body.</li>
  </ol>
  <hr />
  <p>My composable:</p>
  <pre class="lang-js prettyprint-override"><code>// composable/useAuth.js
  const useAuth = () =&gt; {
  
    // user login, sign out, sign up logic
  
    const isLoggedIn = () =&gt; {
      return !!user.value
    }
  
    return {
      isLoggedIn
    }
  }
  
  export default useAuth
  </code></pre>
  <p>My middleware:</p>
  <pre class="lang-js prettyprint-override"><code>// middleware/check-admin.js
  export default defineNuxtRouteMiddleware((to, from) =&gt; {
    const { isLoggedIn } = useAuth()
  
    console.log(isLoggedIn); // &lt;- Screenshot
  
    if (isLoggedIn) {
      return navigateTo(`/albums/${to.params.id}/edit`)
    } else {
      return navigateTo('/')
    }
  })
  </code></pre>
  <p>My console logs a method body. But I expected a falsy or truthy value:
  <a href="https://i.stack.imgur.com/vNmMo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vNmMo.png" alt="enter image description here" /></a></p>
  <hr />
  <h3>Problems:</h3>
  <ul>
  <li>How can I read a boolean value from my composables to pass the test inside the middleware?</li>
  <li>It is okay to use <code>navigateTo</code> to abort the routing, if the user got no credentials? The docs says, I can use <code>abortNavigation()</code></li>
  </ul>