Exposing FetchOptions Type with Better-Auth?

It seems that if I want the type definition of FetchOptions. I need to install @better-fetch/fetch
import type { BetterFetchOption } from '@better-fetch/fetch'
import type { BetterFetchOption } from '@better-fetch/fetch'
Use Case, using Tanstack Query with better-auth. Below is my mutationFn to be passed to Tanstack Query.
import { authClient } from "$lib/auth";
import type { BetterFetchOption } from '@better-fetch/fetch'

type SignUpEmailInput = {
email: string
name: string
password: string
displayUsername?: string
image?: string
callbackUrl?: string
username?: string
}

export const signUpEmail = async ({
data,
fetchOptions
}: {
data: SignUpEmailInput;
fetchOptions?: BetterFetchOption
}) => {
return authClient.signUp.email({ ...data, fetchOptions });
import { authClient } from "$lib/auth";
import type { BetterFetchOption } from '@better-fetch/fetch'

type SignUpEmailInput = {
email: string
name: string
password: string
displayUsername?: string
image?: string
callbackUrl?: string
username?: string
}

export const signUpEmail = async ({
data,
fetchOptions
}: {
data: SignUpEmailInput;
fetchOptions?: BetterFetchOption
}) => {
return authClient.signUp.email({ ...data, fetchOptions });
1 Reply
Acro
AcroOP2mo ago
Actually...have no idea why I'm creating a wrapper function...and just pass authClient.signUp.email as is to mutationFn and everything will be inferred...

Did you find this page helpful?