Skip to main content

API surface

Reference of auto-imported composables, server helpers, aliases, and package entries.

This page lists the auto-imported composables, server helpers, aliases, and package entries. The source of truth is src/module-api-surface.ts for auto-imports, each package's exports in package.json, and the type declarations that ship with each package. Update this page in the same pull request that changes one of them.

Nuxt aliases

AliasPoints toUse it in
#convex/apiYour app's convex/_generated/apiVue components, composables, route middleware, Nitro server routes, tests
#convex/serverThe @lupinum/better-convex-nuxt/server exportsNitro server routes and server utilities
#convex/auth-clientThe Better Auth client definition from convex.auth.clientAuth-enabled builds only

Use #convex/api for generated Convex functions:

ts
import { api } from '#convex/api'

Before Convex creates convex/_generated/api, this alias points to a placeholder. Imports still compile. Reading a function from it throws an error that tells you to run Convex codegen.

Published package entries

ImportRuntime exportsType exports
@lupinum/better-convex-nuxtdefaultConvexAuthMode, ConvexAuthOptions, ConvexAuthStatus, ConvexCallError, ConvexCallErrorCode, ConvexCallOutcome, ConvexCallStatus, ConvexClientHandle, ConvexFileUploadResult, ConvexFormError, ConvexFormErrorKind, ConvexFormErrorMapping, ConvexFormIssue, ConvexFormSubmitResult, ConvexOperation, ConvexOperationUploadOptions, ConvexOperationWork, ConvexQueryArgs, ConvexQueryBlockedBy, ConvexRuntimeConfig, ConvexUploadPhase, ConvexUser, ModuleOptions, NuxtConvexPaginatedQuery, NuxtConvexQuery, OptimisticUpdate, PaginatedQueryArgs, PaginatedQueryItem, UploadComplete, UploadCompleteContext, UploadProgressInfo, UploadUrlMutation, UseConvexActionReturn, UseConvexAuthReturn, UseConvexConnectionStateReturn, UseConvexFormReturn, UseConvexFileUploadOptions, UseConvexFileUploadReturn, UseConvexMutationOptions, UseConvexMutationReturn, UseConvexOperationReturn, UseConvexPaginatedQueryState, UseConvexQueryParameters, UseConvexQueryState, UseNuxtConvexPaginatedQueryOptions, UseNuxtConvexQueryOptions
@lupinum/better-convex-nuxt/errorsConvexCallError, ConvexFormError, isConvexCallError, normalizeConvexError, isSerializedConvexCallErrorConvexCallErrorCode, ConvexCallErrorKind, ConvexCallErrorInput, ConvexCallOutcome, ConvexFormErrorKind, ConvexFormIssue, ConvexUploadPhase, SerializedConvexCallError
@lupinum/better-convex-nuxt/testinvalidCursorError, setupBetterConvexTestBetterConvexTestAuth, BetterConvexTestAuthPreset, BetterConvexTestAuthResult, BetterConvexTestOperationControl, BetterConvexTestOptions, BetterConvexTestPaginatedQueryControl, BetterConvexTestQueryCall, BetterConvexTestQueryControl, BetterConvexTestRequest, BetterConvexTestRuntime, BetterConvexTestStorageControl, BetterConvexTestStorageRequest, BetterConvexTestUploadCall, BetterConvexTestUploadControl, BetterConvexTestUploadOptions
@lupinum/better-convex-nuxt/better-auth/clientdefineConvexAuthClientBaseAuthClient, ConvexAuthClientDefinition, ConvexAuthClientRegistry, InferRegisteredConvexAuthClient, IntegratedAuthClient
@lupinum/better-convex-nuxt/better-auth/servercreateBetterConvexAuth, createUserProjectionTriggers, defineAuthAdapterFunctions, findAccountKeyCollisions, getConvexAuthProvider, mcpPrincipalValidator, requireAuthOriginAccountKeyCollision, AccountKeyCollisionReport, AuthComponentTriggers, AuthCtx, AuthFunctions, BetterAuthMcpAccessVerifierOptions, BetterAuthUserProjectionSource, BetterConvexAccountPolicy, BetterConvexAuth, BetterConvexAuthEmail, BetterConvexAuthEmailSender, BetterConvexAuthEmailType, BetterConvexAuthEmailUser, BetterConvexAuthInstance, BetterConvexAuthUser, BetterConvexHttpSession, BetterConvexMcp, BetterConvexMcpAccessVerifier, BetterConvexMcpHost, BetterConvexMcpOptions, BetterConvexMcpPrincipal, BetterConvexOAuthConnection, BetterConvexOAuthConnections, BetterConvexOAuthOperator, BetterConvexOrganizationAuthInstance, BetterConvexPublicOAuthClientInput, BetterConvexSessionHttpHandler, BetterConvexSessionPolicy, BetterConvexTeamOrganizationAuthInstance, CreateAuth, CreateBetterConvexAuthOptions, CreateUserProjectionTriggersOptions, FindAccountKeyCollisionsOptions, McpAccessErrorCode, VerifiedBetterConvexMcpAccess, WritableAuthCtx
@lupinum/better-convex-nuxt/better-auth/convex.configdefault—
@lupinum/better-convex-nuxt/better-auth/_generated/component.js—ComponentApi
@lupinum/better-convex-nuxt/better-auth/testcreateBetterConvexTestAuth, default, register, signInAsBetterConvexTestAuthInstance, SignInAsOptions, SignInAsTestClient
@lupinum/better-convex-nuxt/servergetConvexUser, requireConvexUser, serverConvex, ServerConvexValidationError, toConvexH3ErrorConvexCredential, ServerConvexCaller, ServerConvexOptions

Import from #convex/server when you want an explicit import instead of a Nitro auto-import, or when the export is not auto-imported:

ts
import { requireConvexUser, serverConvex } from '#convex/server'

Code in your convex/ folder imports the Better Auth helpers, such as createUserProjectionTriggers, from the better-auth/server entry:

ts
import { createUserProjectionTriggers } from '@lupinum/better-convex-nuxt/better-auth/server'

Core composable auto-imports

Every build auto-imports these composables. When you omit convex.auth, the module does not install Better Auth, the auth proxy, the auth route middleware, the convexAuth page metadata, or useConvexAuth.

NameKindPurposeGuide
useConvexComposableReturns one stable handle with query, mutation, action, and onUpdate for direct Convex calls.Guide
useConvexActionComposableRuns a Convex action. Returns run(), data, status, pending, error, and reset().Guide
useConvexAttachmentComposableReturns the browser attachment that an embedded Vue application passes to createBetterConvex. It contains no credentials.Guide
useConvexConfigComposableReturns the readonly public Convex deployment URLs.Guide
useConvexConnectionStateComposableReturns the live Convex connection state and the pending mutation and action counts.Guide
useConvexFileUploadComposableUploads one file at a time to Convex storage with progress, an optional complete step, cancel(), and reset().Guide
useConvexFormComposableValidates form values with a Standard Schema and submits them to one Convex mutation.Guide
useConvexMutationComposableRuns a Convex mutation. Returns mutate(), data, status, pending, error, and reset().Guide
useConvexOperationComposableRuns several Convex calls and uploads as one operation for the signed-in user who started it. Returns run(), data, status, pending, error, and reset().Guide
useConvexPaginatedQueryComposableLoads a paginated Convex query. The server renders the first page, and the browser loads more pages and keeps them live.Guide
useConvexQueryComposableLoads a Convex query. The server renders it, and the browser keeps it live.Guide

useConvexQuery options: auth, keepPreviousData, immediate, server, and lazy. It returns data, status, pending, error, isStale, blockedBy, execute(), and refresh().

useConvexPaginatedQuery options: initialNumItems, initialCursor, auth, keepPreviousData, immediate, server, and lazy. initialNumItems is required and must be a positive integer. It returns data, status, pending, error, isStale, blockedBy, canLoadMore, isLoadingMore, isExhausted, loadMore(), execute(), refresh(), and reset(). status and pending describe the first page only. loadMore() returns a Promise that never rejects.

In plain Vue, the query options do not include server or lazy.

useConvexMutation returns mutate(), data, status, pending, error, and reset(). useConvexAction returns run(), data, status, pending, error, and reset(). Destructure the result: const { mutate, pending, error } = useConvexMutation(api.notes.create).

Auth-enabled auto-imports

Authentication is off until you add a convex.auth object:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@lupinum/better-convex-nuxt'],
  convex: {
    auth: {
      origin: process.env.SITE_URL ?? 'http://localhost:3000',
      trustedClientIpHeader: process.env.BCN_AUTH_TRUSTED_CLIENT_IP_HEADER,
    },
  },
})

Only an auth-enabled build auto-imports the API below. To add Better Auth client plugins, define the client with defineConvexAuthClient from @lupinum/better-convex-nuxt/better-auth/client and set convex.auth.client to that file. Use the client through useConvexAuth().client.

NameKindPurposeGuide
normalizeLocalRedirectPathHelperReturns a safe local application path, or null for any other value.Guide
useConvexAuthComposableReturns auth status, pending, user, error, the Better Auth client, and ready().Guide
useConvexAuthReturnToComposableReturns the validated local return path from the sign-in redirect query.Guide

Render auth UI with ordinary Vue conditionals on status, pending, and error. The module does not register auth UI components.

Server auto-imports

NameKindPurposeGuide
getConvexUserServer helperReads the signed-in user for the request, or null when it is anonymous.Guide
requireConvexUserServer helperReads the signed-in user for the request, or throws an H3 401 error.Guide
serverConvexServer helperCreates a caller for one Nitro request. It has getToken(), query(), mutation(), and action().Guide
toConvexH3ErrorServer helperMaps any thrown value to an H3 error whose data is the serialized ConvexCallError.Guide