Skip to main content
RapidDev - Software Development Agency
lovable-issues

Instructing Lovable to Use Specific Frameworks or Libraries

To make Lovable use a specific npm package or framework, name it explicitly in your prompt with the exact package name and version. For example: 'Use the @tanstack/react-query package to fetch and cache user data.' Add an AGENTS.md file to your project root listing preferred libraries so Lovable uses them consistently across all future prompts.

Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read~5 minAll Lovable projectsMarch 2026RapidDev Engineering Team
TL;DR

To make Lovable use a specific npm package or framework, name it explicitly in your prompt with the exact package name and version. For example: 'Use the @tanstack/react-query package to fetch and cache user data.' Add an AGENTS.md file to your project root listing preferred libraries so Lovable uses them consistently across all future prompts.

Why Lovable sometimes ignores your framework or library preferences

Lovable's AI generates code using its default stack: React, TypeScript, Tailwind CSS, and shadcn/ui. When you ask for a feature without specifying which library to use, Lovable picks whatever it considers the best fit — which may not match your preference. For example, asking 'add drag-and-drop to my board' might produce custom pointer event handlers instead of using the hello-pangea/dnd package you wanted. The AI does not remember preferences between sessions unless you write them down. If you told Lovable to use Zustand for state in one prompt, it might switch back to useState in the next prompt because the context window has moved past your earlier instruction. This is not a bug — it is how large language models work with conversation context. The permanent solution is AGENTS.md, a special file in your project root that Lovable reads at the start of every session. Put your library preferences there, and Lovable follows them consistently without you repeating yourself in every prompt.

  • Prompt does not name the specific package — Lovable defaults to its built-in preferences
  • Library preference was mentioned in an earlier prompt that has scrolled out of the context window
  • No AGENTS.md file exists to persist technology choices across sessions
  • Package name is misspelled or uses the wrong scope — Lovable cannot install a package it cannot find
  • The requested package is incompatible with React or Vite — Lovable silently falls back to an alternative

Error messages you might see

Module not found: Error: Can't resolve 'some-package'

Lovable tried to import a package that was not installed. This happens when you reference a library name in code but did not prompt Lovable to install it. Ask Lovable to add the package to your project.

Could not resolve dependency: npm ERR! peer react@"^16.8 || ^17" from some-package

The package requires an older version of React than what Lovable uses (React 18+). Look for an updated version of the package that supports React 18, or choose a compatible alternative.

TypeError: someLibrary.default is not a function

The import syntax does not match the package's export format. Some packages use named exports while others use default exports. Check the package documentation for the correct import syntax.

Before you start

  • A Lovable project open in the editor
  • The exact npm package name you want to use (check npmjs.com for the correct name and scope)
  • A clear idea of what feature the package should provide in your app

How to fix it

1

Name the exact package in your prompt

Lovable installs and uses whatever package you specify by name, but it cannot guess your preference from vague descriptions

When you want Lovable to use a specific library, include the exact npm package name in your prompt. Be specific about what it should do with the library. Instead of 'add charts to my dashboard', say 'Use the recharts npm package to add a line chart showing monthly revenue on my Dashboard page. The data comes from the revenue table in Supabase.' Lovable will install the package and generate code using it.

Expected result: Lovable installs the specified package and uses it in the generated code.

2

Create an AGENTS.md file for persistent preferences

AGENTS.md is read at the start of every AI session, so your library choices persist without repeating them in every prompt

Open Dev Mode (click the + button, then Code) and create a new file called AGENTS.md in the project root. Add your technology preferences as clear instructions. Lovable reads this file automatically at the start of every new session, so it will follow these rules for all future prompts. You can also prompt Lovable directly: 'Create an AGENTS.md file in the project root with the following preferences.' Then list your preferred libraries.

typescript
1# AGENTS.md
2
3## Technology Preferences
4
5- Use @tanstack/react-query for all data fetching and caching
6- Use zustand for global state management (not Redux or Context)
7- Use recharts for all charts and data visualization
8- Use @hello-pangea/dnd for drag-and-drop functionality
9- Use date-fns for date formatting and manipulation (not moment.js)
10- Use zod for all schema validation
11- Use react-hook-form with zod resolver for all forms
12
13## Code Style
14
15- Always use TypeScript strict mode
16- Prefer named exports over default exports
17- Use absolute imports with the @/ alias

Expected result: All future Lovable sessions automatically read AGENTS.md and follow your library preferences.

3

Verify the package was installed correctly

Sometimes Lovable installs the package but uses the wrong import path or API, especially for packages with recent breaking changes

After Lovable generates code with your specified library, check that it works by looking at the preview. If you see a 'Module not found' error, the package may not have been added to package.json. Open Dev Mode and check package.json to confirm the package is listed under dependencies. If it is missing, prompt Lovable: 'Add [package-name] to the project dependencies and update the import statements.' If the code runs but does not behave as expected, the AI may be using an outdated API. Prompt: 'Update the [package-name] usage to match the latest v[X] API documentation.'

Before
typescript
// package.json — package is missing
{
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
}
After
typescript
// package.json — package is correctly installed
{
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"recharts": "^2.12.0"
}
}

Expected result: The package appears in package.json dependencies and the import works without errors in the preview.

4

Handle incompatible packages gracefully

Some npm packages are not compatible with React 18, Vite, or browser-only environments — Lovable cannot warn you about this

If a package causes build errors after installation, check its npm page for React 18 compatibility. Common incompatibilities include: packages that require Node.js APIs (fs, path) which do not exist in the browser, packages pinned to React 16/17 with peer dependency conflicts, and packages that use CommonJS (require()) instead of ES Modules (import). If the package is incompatible, prompt Lovable to suggest a compatible alternative: 'The [package-name] package is not compatible with this project. What is a React 18 and Vite compatible alternative for [feature]?'

Expected result: Lovable suggests a compatible alternative package and implements the feature using it.

Complete code example

AGENTS.md
1# Project Technology Standards
2
3## Required Libraries
4
5Always use these packages for the specified purposes:
6
7| Purpose | Package | Notes |
8|---------|---------|-------|
9| Data fetching | @tanstack/react-query | Use useQuery and useMutation hooks |
10| Forms | react-hook-form + zod | Always use zodResolver for validation |
11| State management | zustand | For global state only; use useState for local |
12| Charts | recharts | Use ResponsiveContainer wrapper |
13| Dates | date-fns | Never use moment.js |
14| Drag and drop | @hello-pangea/dnd | For sortable lists and boards |
15| Animations | framer-motion | For page transitions and micro-interactions |
16| Icons | lucide-react | Already included via shadcn/ui |
17
18## Code Conventions
19
20- Use TypeScript strict mode for all files
21- Prefer named exports: export function Component() {}
22- Use the @/ import alias for all project imports
23- Place new components in src/components/
24- Place new pages in src/pages/
25- Place new hooks in src/hooks/
26- Place new utility functions in src/lib/
27
28## Do Not Use
29
30- Redux (use zustand instead)
31- Axios (use @tanstack/react-query with fetch)
32- moment.js (use date-fns)
33- CSS modules (use Tailwind CSS)
34- jQuery (not compatible with React)

Best practices to prevent this

  • Always include the exact npm package name (with scope like @tanstack/react-query) in your prompt — Lovable cannot guess from descriptions alone
  • Create an AGENTS.md file early in your project to establish technology preferences before Lovable generates code with its defaults
  • Check npmjs.com for the correct package name and React 18 compatibility before asking Lovable to install it
  • Include version requirements when precision matters: 'Use recharts version 2.x' prevents the AI from targeting outdated APIs
  • List packages you do NOT want in AGENTS.md (like moment.js or jQuery) to prevent Lovable from defaulting to them
  • When requesting a feature, describe both the library AND the desired behavior: 'Use framer-motion to animate page transitions with a fade effect'
  • Verify the generated import paths match the package documentation — Lovable sometimes uses outdated or incorrect import syntax

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I am building a Lovable.dev project (React + TypeScript + Vite + Tailwind) and I need to use specific npm packages instead of Lovable's defaults. The packages I want to use: - [list your preferred packages with their npm names] The features they should provide: - [describe what each package should do] Please help me: 1. Write an AGENTS.md file that tells Lovable to always use these packages 2. Check if any of these packages have React 18 or Vite compatibility issues 3. Show me the correct import syntax for each package 4. Suggest alternatives for any that are incompatible

Lovable Prompt

Create an AGENTS.md file in the project root that specifies our technology preferences. We want to use: @tanstack/react-query for data fetching, zustand for state management, react-hook-form with zod for forms, recharts for charts, and date-fns for date handling. Include a 'Do Not Use' section listing Redux, Axios, moment.js, and jQuery. Format it as a clear reference that you will follow in all future sessions.

Frequently asked questions

How do I tell Lovable to use a specific npm package?

Include the exact package name in your prompt. For example: 'Use the @hello-pangea/dnd npm package to add drag-and-drop functionality to my Kanban board.' Lovable will install the package and generate code using it.

Does Lovable remember my library preferences between sessions?

Not automatically. Each new session starts fresh. To persist preferences, create an AGENTS.md file in your project root listing your preferred packages. Lovable reads this file at the start of every session.

Can Lovable install any npm package?

Lovable can install most public npm packages. However, packages that require Node.js APIs (like fs or path), packages incompatible with React 18, or packages that only support CommonJS will cause build errors. Private packages require adding npm tokens in Workspace Settings then Build Secrets.

What is AGENTS.md and how does it work?

AGENTS.md is a special Markdown file in your project root that Lovable reads at the start of every session. It acts as persistent instructions for the AI agent. Use it to define technology preferences, code style rules, and packages to avoid.

How do I prevent Lovable from using a specific library?

Add a 'Do Not Use' section to your AGENTS.md file listing the packages you want to avoid. For example: 'Do not use moment.js — use date-fns instead.' Lovable will follow this instruction in all future sessions.

Why did Lovable use a different library than what I requested?

Check your prompt for specificity. If you said 'add charts' without naming recharts, Lovable may have chosen a different chart library. Also check if the package you named is compatible with React 18 and Vite — Lovable may silently fall back to an alternative if the requested package causes errors.

What if I can't fix this myself?

If you need to migrate from one library to another across many generated components, or if package compatibility issues require architectural changes, RapidDev's engineers have handled library migrations across 600+ Lovable projects and can ensure a clean transition.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your issue.

Book a free consultation

Need help with your Lovable project?

Our experts have built 600+ apps and can solve your issue fast. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.