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
next- Frameworkreact- UI librarytypescript- Type safetytailwindcss- Styling
shadcn/ui Dependencies
@radix-ui/*- Headless componentslucide-react- Iconsclsx- Class utilitiestailwind-merge- Tailwind class merging
Database
@supabase/supabase-js- 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
Add Email
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:Server vs Client Packages
Server-Only
Some packages should only run on server:Client-Only
Some packages need browser APIs: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

