createResource in SolidJS

From the SolidJS cheat sheet · Resources & Data Fetching · verified Jul 2026

createResource

Fetch async data reactively with automatic loading/error tracking and optional source signals.

tsx
// Quick Reference
import { createResource } from "solid-js";

const [data] = createResource(fetchData);
// data(), data.loading, data.error
💡 Pass a source signal as the first arg to auto-refetch when it changes
⚡ mutate() updates the local data optimistically without refetching
📌 refetch() manually triggers a new fetch — great for refresh buttons or polling
🟢 Combine with Suspense and ErrorBoundary for declarative loading states
resourceasyncfetching
Back to the full SolidJS cheat sheet