feat: add $effect.allowed rune

#16458

Closing issue

Pull request

Open
O
Ocean-OS
Jul 20, 2025, 8:53 PM

This adds the $effect.allowed rune, an advanced feature that indicates whether an effect or async derived can be created in the current context. Effects and async deriveds can only be created when a root effect is active, and previously, the only way to know this was to try creating an effect and checking if it threw an error. Closes #16366.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Info

Assignees None
Reviewers None
Labels None
Milestone None