Skip to content

useQwikMethodUsage

biome.json
{
"linter": {
"rules": {
"nursery": {
"useQwikMethodUsage": "error"
}
}
}
}

Disallow use* hooks outside of component$ or other use* hooks in Qwik applications.

Ensures Qwik’s lifecycle hooks are only used in valid reactive contexts. See Qwik Component Lifecycle for proper hook usage.

import { useSignal } from "@builder.io/qwik";
export const Counter = () => {
const count = useSignal(0);
};
code-block.js:4:17 lint/nursery/useQwikMethodUsage ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Qwik hook detected outside of an allowed scope.

3 │ export const Counter = () => {
> 4 │ const count = useSignal(0);
^^^^^^^^^^^^
5 │ };
6 │

Qwik’s reactive hooks (functions starting with use* followed by uppercase letter) must be:
- Used exclusively within component$ functions
- Or encapsulated within other valid Qwik hooks

Check the Qwik documentation.

import { component$, useSignal } from "@builder.io/qwik";
export const Counter = component$(() => {
const count = useSignal(0);
});
export const useCounter = () => {
const count = useSignal(0);
return count;
};