We can add information about the authenticated user to pageContext at the server middlware:

// `vite-plugin-ssr` server middleware
app.get('*', async (req, res) => {
  // Authentication middlewares (e.g. Passport.js or Grant) provide information
  // about the logged-in user on the `req` object.
  const user = req.user

  /* Or when using a third-party authentication provider (e.g. Auth0):
  const user = await authProviderApi.getUser(req.headers)

  const pageContextInit = {
    urlOriginal: req.url,
    // We make logged-in user information available to pages as `pageContextInit.user`
  const result = await renderPage(pageContextInit)

  /* ... */

Common auth tools:

In principle, we can use vite-plugin-ssr with any authentication tool. Create a new discussion on GitHub if you have questions or if you want help with integrating an authentication tool.