### Server Action Setup for GET Requests Source: https://github.com/billymaulana/nuxt-actions/blob/main/docs/guide/action-queries.md Provides an example of how to define a server action for GET requests using Nuxt Actions, including input validation with Zod. ```typescript // server/actions/list-todos.get.ts import { z } from 'zod' export default defineAction({ input: z.object({ q: z.string().optional(), }), handler: async ({ input }) => { return await db.todo.findMany({ where: input.q ? { title: { contains: input.q } } : undefined, }) }, }) ``` -------------------------------- ### Clone and Install Dependencies Source: https://github.com/billymaulana/nuxt-actions/blob/main/CONTRIBUTING.md Clone the repository, navigate into the directory, and install project dependencies using pnpm. ```bash git clone https://github.com/billymaulana/nuxt-actions.git cd nuxt-actions pnpm install ``` -------------------------------- ### Progress Bar Example with useStreamAction Source: https://github.com/billymaulana/nuxt-actions/blob/main/docs/guide/streaming.md Demonstrates how to use the `useStreamAction` composable to display a real-time progress bar and file name during a streaming process. Requires setup with `processFiles` action and provides callbacks for completion. ```vue ``` -------------------------------- ### All useAction Callbacks Example Source: https://github.com/billymaulana/nuxt-actions/blob/main/docs/api/use-action.md An example showcasing all available callbacks: `onExecute`, `onSuccess`, `onError`, and `onSettled`, with console logging and UI updates. ```ts const { execute } = useAction('/api/todos', { method: 'POST', onExecute(input) { console.log('Sending:', input) loadingOverlay.show() }, onSuccess(data) { console.log('Created:', data) todos.value.push(data) }, onError(error) { console.error('Failed:', error.code, error.message) if (error.fieldErrors) { formErrors.value = error.fieldErrors } }, onSettled(result) { loadingOverlay.hide() console.log('Settled:', result.success ? 'success' : 'error') }, }) ``` -------------------------------- ### Install validation libraries Source: https://github.com/billymaulana/nuxt-actions/blob/main/docs/guide/getting-started.md Install a compatible validation library such as Zod, Valibot, or ArkType. ```bash pnpm add zod ``` ```bash pnpm add valibot ``` ```bash pnpm add arktype ``` -------------------------------- ### Cursor-Based Pagination Setup Source: https://github.com/billymaulana/nuxt-actions/blob/main/docs/guide/infinite-queries.md Demonstrates the setup for cursor-based pagination using `useInfiniteActionQuery`. It specifies how to extract the `nextCursor` from the last page to fetch subsequent pages. ```typescript const { pages, fetchNextPage } = useInfiniteActionQuery( listItems, undefined, { getNextPageParam: (lastPage) => lastPage.nextCursor, }, ) ``` -------------------------------- ### Prepare for Development Source: https://github.com/billymaulana/nuxt-actions/blob/main/CONTRIBUTING.md Generate type stubs and start the development server with the playground environment. ```bash pnpm run dev:prepare pnpm run dev ``` -------------------------------- ### Complete Contact Form Example Source: https://github.com/billymaulana/nuxt-actions/blob/main/docs/guide/use-action.md A full example demonstrating input handling, loading states, error display, and success feedback for a contact form using useAction. ```vue