Skip to content

Instantly share code, notes, and snippets.

@empresarrollo
empresarrollo / useFormSimple.ts
Created September 18, 2025 16:24
Inertia.js Form Helper for Axios/API calls. It wraps Inertia's useForm OR use axios for api calls if you pass {isInertia: false} in the options object.
import { useForm } from '@inertiajs/vue3'
import type { InertiaForm } from '@inertiajs/vue3'
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'
import { cloneDeep } from 'lodash-es'
import { onUnmounted } from 'vue'
// Types
export type Method = 'get' | 'post' | 'put' | 'patch' | 'delete'
// Base options that work in both Inertia and Axios modes