
Remix Has a Free API That Makes Web Standards the Best Framework Feature
Remix is the React framework that embraces web standards. Forms, cookies, headers, streams — everything uses the platform APIs you already know. Loaders: Server-Side Data import { json } from " @remix-run/node " ; import { useLoaderData } from " @remix-run/react " ; export async function loader ({ request }) { const url = new URL ( request . url ); const search = url . searchParams . get ( " q " ); const products = await db . product . findMany ({ where : search ? { title : { contains : search } } : {}, take : 20 , }); return json ({ products , search }); } export default function Products () { const { products , search } = useLoaderData (); return ( < Form method = " get " > < input name = " q " defaultValue = { search } / > { products . map ( p => < div key = { p . id } > { p . title } < /div> ) } < /Form > ); } Actions: Mutations via Forms export async function action ({ request }) { const formData = await request . formData (); await db . product . create ({ data : { title : formDa
Continue reading on Dev.to React
Opens in a new tab



