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/nihalnihalani/jachacks-sf-2026 --skill jac-npm-packages-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-npm-packages
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-npm-packages
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-npm-packages-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Jac developers building client-side UIs need to consume third-party npm libraries and manage DOM refs, but the syntax differs from plain JavaScript. This Skill documents how to declare npm packages in jac.toml, import them in .jac files, and use Ref[T] fields, ref forwarding, and React hooks correctly. ## Core Features & Use Cases - npm Package Declaration: Add regular and dev dependencies under [dependencies.npm] in jac.toml, or patch it automatically with jac install --npm. - Import Syntax: Use double-quoted package names with named imports for libraries like recharts, lucide-react, radix-ui, and sonner. - Refs and Ref Forwarding: Declare Ref[T] fields instead of useRef, and forward refs through a trailing Ref parameter so components work as radix asChild trigger children. - React Hooks: Import useCallback, useMemo, useContext, and createContext directly from react alongside Jac sugar like has and can with entry. - Use Case: When adding a chart to a Jac app, declare recharts in jac.toml, run jac install, import ResponsiveContainer and LineChart, and wire a Ref[HTMLInputElement] for any focusable inputs. ## Quick Start Add the recharts npm package to my Jac project and show me how to import and use a LineChart component in a client .jac file.

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 in jac.toml under [dependencies.npm] for regular deps 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 packages in Jac client files?▼

Use the package name in double quotes with named imports only, for example: import from "recharts" { ResponsiveContainer, LineChart }. Scoped packages like @monaco-editor/react work the same way.

How do I use useRef in Jac components?▼

Do not import useRef directly. Declare a has field typed Ref[T] initialized with Ref(), which lowers to useRef. Access the value via .current after a null check, since it is typed T | None.

Why does my radix DropdownMenuTrigger never open in Jac?▼

The trigger attaches a positioning-anchor ref to its child via asChild. If your component cannot forward refs, the anchor stays null and the menu silently never opens. Add a trailing Ref-typed parameter to opt into forwardRef.

Can I use React hooks like useCallback and useMemo in Jac?▼

Yes, import them directly with import from react { useCallback, useMemo, useContext, createContext }. Mixing these with Jac sugar like has (useState) and can with entry (useEffect) in one component is supported.

What is the difference between consuming and publishing npm packages in Jac?▼

This Skill covers consuming third-party npm packages in Jac client code. To publish a Jac package to npm, refer to the separate jac-packaging Skill instead.