Installing Packages
Via AI
Simply ask:- Add the package to package.json
- Import it where needed
- Use it in your code
Automatic Installation
When AI writes code using a package, it’s automatically installed on next preview refresh.Popular Packages
Forms
| Package | Use Case |
|---|---|
| react-hook-form | Form state management |
| zod | Schema validation |
| @hookform/resolvers | Zod + react-hook-form |
Dates
| Package | Use Case |
|---|---|
| date-fns | Date formatting/manipulation |
| dayjs | Lightweight date library |
UI Enhancements
| Package | Use Case |
|---|---|
| framer-motion | Animations |
| react-hot-toast | Toast notifications |
| sonner | Modern toast library |
Data Fetching
| Package | Use Case |
|---|---|
| @tanstack/react-query | Data fetching & caching |
| swr | Data fetching hooks |
Charts
| Package | Use Case |
|---|---|
| recharts | React charts |
| chart.js | Canvas charts |
| react-chartjs-2 | Chart.js for React |
Utilities
| Package | Use Case |
|---|---|
| lodash | Utility functions |
| clsx | Conditional classes |
| uuid | Generate 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 safetytailwindcss- Styling (Tailwind v4)
UI & Icons
Your interactive React islands can pull from the React 19 ecosystem:lucide-react- Iconsmotion- Animationsradix-ui- Headless, accessible component primitivesclsx- Class utilitiestailwind-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:@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
| Heavy | Lighter Alternative |
|---|---|
| moment.js | date-fns, dayjs |
| lodash | lodash-es, individual imports |
| axios | native 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 aclient:* directive:
Troubleshooting
Package not found
Package not found
- Check package name spelling
- Package might not exist on npm
- Try searching npmjs.com for correct name
Module not found after install
Module not found after install
- Refresh the preview
- Package might need time to install
- Check import path is correct
Types not found
Types not found
- Install @types/package-name
- Some packages include types already
- Check package documentation
Version conflict
Version conflict
- 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

