jac-npm-packages

Configure npm package imports and React refs in Jac client components.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-npm-packages-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-npm-packages
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-npm-packages
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-npm-packages-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers building Jac client applications need to consume third-party npm libraries and manage DOM references, but Jac has its own declaration syntax in jac.toml and its own idioms for refs that differ from plain React. ## Core Features & Use Cases - npm Package Declaration: Add regular and dev dependencies to [dependencies.npm] in jac.toml, or patch it automatically with jac install --npm <pkg>. - Import Syntax: Use double-quoted, named-only imports like import from "recharts" { LineChart } inside .jac client files. - Typed Refs: Declare has inputRef: Ref[HTMLInputElement] = Ref() fields that lower to useRef, plus trailing Ref parameters that lower to forwardRef for radix asChild trigger children. - Use Case: When adding a charting library like recharts to a Jac app and wiring a focusable input, this Skill provides the exact toml entries, import statements, and ref patterns that compile correctly. ## Quick Start Add the sonner npm package to my Jac project and show me how to import its toast function in a client component.

Frequently Asked Questions about jac-npm-packages

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add npm packages to a Jac project?

Declare packages under `[dependencies.npm]` in jac.toml for regular dependencies or `[dependencies.npm.dev]` for build tools, then run `jac install`. Alternatively, run `jac install --npm <pkg>` or `jac install --npm --dev <pkg>` to patch jac.toml automatically.

How do I import npm libraries in Jac client files?

Use named imports with the package name in double quotes, such as `import from "recharts" { LineChart, XAxis }`. Only named imports are supported; default and namespace imports are not available in this syntax.

How do I use useRef in Jac components?

Declare a typed field like `has inputRef: Ref[HTMLInputElement] = Ref()` instead of importing useRef, which is auto-imported by the compiler. Access the value through `.current`, which is typed `T | None` and requires a null check before use.

Why does my radix dropdown menu never open in Jac?

Radix trigger components attach a positioning ref to their child via asChild, so the child must forward refs. Add a trailing parameter typed `Ref` to your component, which lowers to React forwardRef and lets the trigger anchor its menu.

Why does jac check report E1102 requires prop ref?

This is a known false positive when a component's trailing ref parameter has no default value, because the `ref=` JSX attribute is reserved and not counted toward params. Adding a `= Ref()` default silences the error; build output is correct either way.