Skip to main content
Extend your app’s functionality with NPM packages.

Installing Packages

Via AI

Simply ask:
The AI will:
  1. Add the package to package.json
  2. Import it where needed
  3. Use it in your code

Automatic Installation

When AI writes code using a package, it’s automatically installed on next preview refresh.

Forms

PackageUse Case
react-hook-formForm state management
zodSchema validation
@hookform/resolversZod + react-hook-form

Dates

PackageUse Case
date-fnsDate formatting/manipulation
dayjsLightweight date library

UI Enhancements

PackageUse Case
framer-motionAnimations
react-hot-toastToast notifications
sonnerModern toast library

Data Fetching

PackageUse Case
@tanstack/react-queryData fetching & caching
swrData fetching hooks

Charts

PackageUse Case
rechartsReact charts
chart.jsCanvas charts
react-chartjs-2Chart.js for React

Utilities

PackageUse Case
lodashUtility functions
clsxConditional classes
uuidGenerate unique IDs

Using Installed Packages

Once installed, use in your code:

Pre-Installed Packages

These are already available:

Core

  • astro - Framework (static site generator)
  • react - UI library (React 19, for interactive islands)
  • typescript - Type safety
  • tailwindcss - Styling (Tailwind v4)

UI & Icons

Your interactive React islands can pull from the React 19 ecosystem:
  • lucide-react - Icons
  • motion - Animations
  • radix-ui - Headless, accessible component primitives
  • clsx - Class utilities
  • tailwind-merge - Tailwind class merging

Database

  • @/lib/kleap-db - Kleap Database client. Use this for reading and writing data — you don’t need to install a separate database client.

Package Versions

Checking Versions

Ask AI to check or update:

Version Compatibility

The AI typically installs compatible versions. If you need a specific version:

TypeScript Types

Many packages include types. For those that don’t:
This adds @types/lodash.

Common Package Tasks

Add Authentication

Kleap Database includes built-in email/password accounts, so ask for that directly instead of installing a separate auth library:

Add Email Notifications

For an email whenever someone submits a form, use built-in Forms — no package needed. Sending custom transactional email from a static site requires an external provider called from your own backend (advanced):

Add Markdown

Add PDF Generation

Package Size Considerations

Be mindful of bundle size:

Check Size

Use bundlephobia.com to check package sizes.

Lightweight Alternatives

HeavyLighter Alternative
moment.jsdate-fns, dayjs
lodashlodash-es, individual imports
axiosnative fetch

Tree Shaking

Import only what you need:

Build-Time vs Browser Packages

Build-Time Only

Some packages should only run at build time, in Astro frontmatter (the code between the --- fences in a .astro file). This code never ships to the browser:

Browser (Interactive Islands)

Packages that need browser APIs run inside a React island, hydrated with a client:* directive:

Troubleshooting

  • Check package name spelling
  • Package might not exist on npm
  • Try searching npmjs.com for correct name
  • Refresh the preview
  • Package might need time to install
  • Check import path is correct
  • Install @types/package-name
  • Some packages include types already
  • Check package documentation
  • Ask AI to resolve version conflict
  • Check peer dependencies
  • May need to update other packages

Best Practices

Use established packages

Choose well-maintained packages with good documentation

Check bundle size

Consider impact on app performance

Import selectively

Import only functions you need

Keep updated

Update packages for security fixes

Custom Fonts

Add typography packages