---
title: "Server Auto-imports"
description: "Every helper auto-imported into Nitro server code — the one-shot fetch functions, SSR preloading, and the Better Auth request-scoped auth service."
canonical_url: "https://nuxt-convex-module.dev/api-reference/server-imports"
---
# Server Auto-imports

> Every helper auto-imported into Nitro server code — the one-shot fetch functions, SSR preloading, and the Better Auth request-scoped auth service.

Auto-imported in Nitro server code — server routes, API handlers, server middleware, and Nitro plugins (a port of `convex/nextjs`). App code that runs during SSR (a page's `useAsyncData`, `<script setup>`) does **not** get these auto-imports: there, import them explicitly from `nuxt-convex-module/server`.

For what is auto-imported into app code instead, see [app auto-imports](https://nuxt-convex-module.dev/api-reference/auto-imports).

## Data and preloading

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        fetchQuery
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-convex-module.dev/guide/server-and-ssr#one-shot-calls">
        One-shot query
      </a>
      
       over HTTP.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fetchMutation
      </code>
    </td>
    
    <td>
      One-shot mutation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fetchAction
      </code>
    </td>
    
    <td>
      One-shot action.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        preloadQuery
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-convex-module.dev/guide/server-and-ssr#preloading-for-ssr">
        Preload a query for SSR hydration
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        preloadedQueryResult
      </code>
    </td>
    
    <td>
      Extract the value from a preloaded query.
    </td>
  </tr>
</tbody>
</table>

`fetchQuery`, `fetchMutation`, `fetchAction` and `preloadQuery` accept a trailing options object after the function args: `{ token?, url?, skipConvexDeploymentUrlCheck? }`. `token` is a JWT for authenticated calls without Better Auth, `url` overrides the deployment URL (defaults to the module's `runtimeConfig.public.convex.url` — resolved at build time from `convex.url`, `NUXT_PUBLIC_CONVEX_URL`, then `CONVEX_URL` — then the `NUXT_PUBLIC_CONVEX_URL` process variable), and `skipConvexDeploymentUrlCheck: true` allows self-hosted URLs that don't look like `*.convex.cloud`. Full signatures: [`server` reference](https://nuxt-convex-module.dev/api-reference/reference/server).

```ts [server/api/messages.get.ts]
import { api } from '#convex/api'

export default defineEventHandler(async (event) => {
  const token = getHeader(event, 'authorization')?.replace('Bearer ', '')
  return fetchQuery(api.messages.list, {}, { token })
})
```

## With `@convex-dev/better-auth`

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        convexAuth(event, opts?)
      </code>
    </td>
    
    <td>
      A request-scoped, authenticated helper service (<code>
        getToken
      </code>
      
      , <code>
        isAuthenticated
      </code>
      
      , <code>
        fetchAuth*
      </code>
      
      , <code>
        preloadAuthQuery
      </code>
      
      , and <code>
        handler
      </code>
      
       — the <a href="https://nuxt-convex-module.dev/components/better-auth">
        Better Auth
      </a>
      
       route proxy, the Nuxt analog of upstream's <code>
        nextJsHandler
      </code>
      
      ). Alias: <code>
        convexBetterAuthNuxt
      </code>
      
      .
    </td>
  </tr>
</tbody>
</table>

The optional second argument extends `GetTokenOptions` from `@convex-dev/better-auth/utils` with a `convexSiteUrl` override (defaults to `runtimeConfig.convex.siteUrl`, then `runtimeConfig.public.convex.siteUrl`, then the `NUXT_PUBLIC_CONVEX_SITE_URL` process variable) and a `convexUrl` key that is accepted and ignored, so upstream call sites drop in unchanged. Full signatures: [`better-auth/server` reference](https://nuxt-convex-module.dev/api-reference/reference/better-auth/server).

Import the `fetch*` / `preload*` helpers directly (outside auto-import contexts) from `nuxt-convex-module/server`; `convexAuth` comes from `nuxt-convex-module/better-auth/server`.


## Sitemap

See the full [sitemap](https://nuxt-convex-module.dev/sitemap.md) for all pages.
