0Pricing
Sveltejs Academy · Lesson

setContext() and getContext()

Provide and consume context values scoped to a component subtree.

What is Context

Context lets a parent component pass data to all its descendants without prop drilling.

Import Helpers

From svelte.

import { setContext, getContext } from "svelte";

All lessons in this course

  1. setContext() and getContext()
  2. Context vs Stores: When to Use Each
  3. Typed Context with TypeScript
  4. Context for Dependency Injection
← Back to Sveltejs Academy