Skip to content

Instantly share code, notes, and snippets.

View AlemTuzlak's full-sized avatar

Alem Tuzlak AlemTuzlak

View GitHub Profile
@AlemTuzlak
AlemTuzlak / gist:89ee03a57c97cb820d6c30d7cd88b341
Created August 10, 2023 09:31
Type inference with zod and remix-hook-form
import type { ZodType, z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { getValidatedFormData as getValidatedFormDataPrimitive, useRemixForm as useForm, UseRemixFormOptions } from "remix-hook-form";
interface UseRemixFormZodOptions<T extends ZodType, U extends FromZodType<T>> extends UseRemixFormOptions<U> {
schema: T;
}
export type FromZodType<T extends ZodType> = z.infer<T>;
@AlemTuzlak
AlemTuzlak / gist:11d1b9aa8b5e21eb08af0a73763855e3
Created March 2, 2024 11:12
react-query adapter for remix
import { QueryClient } from "@tanstack/react-query";
import { CacheAdapter, createCacheAdapter } from "remix-client-cache";
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5,
},
},
});
@AlemTuzlak
AlemTuzlak / gist:9ecd385e7e3b57ba80c36914123800e8
Created March 2, 2024 11:12
react-query adapter for remix
import { QueryClient } from "@tanstack/react-query";
import { CacheAdapter, createCacheAdapter } from "remix-client-cache";
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5,
},
},
});
@AlemTuzlak
AlemTuzlak / index.ts
Last active July 16, 2024 16:36
Hono auto-infer app context
// Your app load context function that generates the remix context object
const generateAppLoadContext = async (c: Context, build: ServerBuild) => {
// example with i18n
const locale = i18next.getLocale(c);
const t = await i18next.getFixedT(c);
return {
appVersion: "v1.0",
lang: locale,
t,