Examples
Each example below is a page in the example app in the nuxt-actions repository. Every page here shows the server action and the component that calls it, runs the page live right where you read it, and links to the full source on GitHub.
Calling actions
- CRUD ActionsCreate and list todos with typed action references imported from #actions.
- Form ActionsuseFormAction with field-level validation errors, dirty tracking, and reset.
- Batch ExecutionRun several actions in parallel with useActions and read each result on its own.
- Progressive EnhancementuseActionState for forms that keep working when JavaScript is disabled.
Queries and caching
- SSR QueriesServer-rendered queries with debounced search and automatic refetching.
- Polling & Auto-RefetchrefetchInterval, refetchOnFocus, the enabled toggle, and transform on useActionQuery.
- Infinite ScrollLoad a list one page at a time with useInfiniteActionQuery, fetchNextPage, and hasNextPage.
- Smart Cache InvalidationuseActionMutation with tags, so a write refetches every query that depends on it.
- Server CacheCache a slow GET action on the server with the cache option, and drop the result after a write with invalidateActionCache.
- Prefetch & Stream CacheWarm the cache on hover with prefetchAction and keep streamed results with useStreamActionQuery.
Interactive UI
- Optimistic UpdatesToggle a todo instantly and roll back automatically when the server rejects the change.
- StreamingStream generated text over Server-Sent Events and render each chunk as it arrives.
- File UploadsParse multipart/form-data into typed file fields, with an avatar preview and an upload progress bar.
- ResilienceRetry with exponential backoff and jitter, cancel stale searches, and cancel requests by hand.
Server and security
- Middleware & AuthAn authentication flow built from chained middleware, validation, and typed errors.
- Auth PresetdefineAuthMiddleware resolves ctx.user or rejects the request with a typed 401.
- Security MiddlewareRate limit an action with Retry-After, reject cross-site posts with originMiddleware, and protect a save with csrfMiddleware.
- Idempotent PaymentsReplay duplicate requests with the idempotency option, so a double click never charges twice.
- ObservabilityGlobal action:start, success, error, and settled hooks, plus a call through the grouped actions namespace.
- OpenAPI & Swagger UIGenerate an OpenAPI 3.1 document and Swagger UI from your actions.
Going further
Run the examples locally
bash
git clone https://github.com/billymaulana/nuxt-actions
cd nuxt-actions
pnpm install
pnpm dev:prepare
pnpm --filter nuxt-actions-example devThen open http://localhost:3000 and pick an example, or open the live demo without installing anything.