Skip to content

Conversation

@mmailaender
Copy link
Contributor

@mmailaender mmailaender commented Nov 6, 2025

This PR adds a one-liner that shows how to use the new skip query feature from convex-svelte to conditionally execute a query if a user is authenticated or not.

This solves a common question/problem and avoids a major effect in teardown error that happens if the user tries deriving from a query to run a query like so conditionally in a dynamically mounted component (Dialog, popup, etc.)(More explained in the convex-svelte docs):

// Bad
$derived( isAuthenticated ? useQuery(api.users.queries.getActiveUser, {}) : {} );  

// Good (Enabled with convex-svelte 0.0.12
useQuery(api.auth.getCurrentUser, () => (isAuthenticated ? {} : 'skip'));

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant