Integrating LLMs into an Existing React + Node.js Application
Table of contents ▾
Introduction
You don't need to rebuild a React and Node.js app to add an LLM feature. Under the hood it is mostly ordinary backend and frontend work. These are the patterns I would use, and the ones I'd push back on.
Backend Integration Patterns
Keep the API call on the server
Never call the LLM provider straight from the browser. Put a small Node.js service in between that holds the API key, builds the prompt, applies rate limits and logs each request. It also gives you one place to switch providers later.
Stream the response
For anything that generates text, stream it. Waiting ten seconds for a full answer feels broken; seeing words appear doesn't. Node.js handles Server-Sent Events or WebSockets well, and React can render a stream without much extra code.
Frontend Integration Patterns
Add to what already works
Introduce the AI feature next to an existing workflow, not instead of it. If smarter search sits alongside the old keyword search, users still have something that works when the AI call is slow or fails.
Plan for slow and wrong
LLM responses are slow, sometimes fail and are sometimes wrong. Handle loading, error and retry states on purpose, never block the rest of the UI while waiting, and make it easy for users to tell when an answer came from the model.
Want an LLM feature added to your app? Tell me what you have in mind.
Key Takeaways
- Route every LLM call through your own backend.
- Stream generated text from the start.
- Add AI beside existing features so there's always a fallback.
- Design for slow, failed and wrong responses.
Conclusion
Adding an LLM to an app is now a normal engineering task. Start small, measure cost and quality, and treat it as one feature among many.
Working on something similar?
Tell me about your project or role. I reply within 24 hours.