Instruction file imported from navikt/k9-sak-web (
.github/instructions/v2.instructions.md). Copyright stays with the author.
v2 Package Rules
Imports
- Always use
.jssuffix in import paths, never.tsor no suffix - Never import from non-v2 packages (
@k9-sak-web/utils,@k9-sak-web/types,@k9-sak-web/shared-components, etc.) - Import types directly from files, not from barrel
index.tsre-exports
Backend client
- Use generated types from
@k9-sak-web/backend/<backend>/generated/types.js - Use
queryOptions()from@tanstack/react-queryto define query configs as named exports — enables reuse and prefetching - Never copy or manually duplicate types that can be generated from the OpenAPI spec
Data fetching
- Prefer
useSuspenseQuery— callers must provide<Suspense>and<ErrorBoundary> - Use
useQueryonly when explicitisLoading/isErrorrendering inside the component is needed - Never use the old
rest-api/useRestApihooks in v2 code
API injection
- Backend clients are injected via React Context — never imported directly into components
- The pattern is: interface →
createContext→Fake*class for Storybook
Keep skills up to date
If you change, add, or remove a pattern described above, also ask if we should update .github/skills/v2-architecture/SKILL.md accordingly.