Skip to main content

Installation

Package managers

npm install use-local-llm

Peer dependencies

use-local-llm requires React ≥17 as a peer dependency. If you're using a modern React project (Create React App, Next.js, Vite), React is already installed.

What's included

The package ships:

FormatFileDescription
ESMdist/index.mjsModern ES modules (tree-shakeable)
CJSdist/index.cjsCommonJS for Node.js / older bundlers
Typesdist/index.d.tsFull TypeScript declarations

Bundle size: ~2.8 KB gzipped, zero runtime dependencies.

TypeScript

Full TypeScript support out of the box. No @types/ package needed — types are included.

import type {
Backend,
ChatMessage,
LocalLLMOptions,
LocalLLMResult,
StreamCompletionOptions,
} from "use-local-llm";

CDN (UMD)

For quick prototyping, you can use a CDN (not recommended for production):

<script src="https://unpkg.com/use-local-llm/dist/index.cjs"></script>

Verify installation

import { useOllama } from "use-local-llm";

// If this compiles, you're good ✓
console.log(typeof useOllama); // "function"