This repo shows off Remix HMR + Hot Data Revalidation 🔥
npx create-remix@nightly --template pcattori/remix-hmr-example
npm run dev
Open up localhost:3000
to see your app
Try changing things and getting hot updates!
Add a className
to the <h1/>
in app/routes/index.tsx
:
<h1 className="bg-red-600">Welcome to Remix</h1>
Save the file and see them hot update. Feel free to keep changing them!
Add an <h2/>
to app/routes/index.tsx
:
<h2>blah</h2>
Or change the content in the <h1/>
:
<h1 className="bg-red-600">Welcome to HMR + HDR 🔥</h1>
This is where the magic ✨ of HDR comes in.
Add a loader:
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
export let loader = () => json({ hello: "world" });
export default function Index() {
let { hello } = useLoaderData<typeof loader>();
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Welcome to Remix</h1>
<h2>{hello}</h2>
{/* rest of the code */}
</div>
);
}
Then try changing the loader data:
export let loader = () => json({ hello: "planet" });