> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/ai/vector-stores/javascript-typescript.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# JavaScript / TypeScript

Set `serverConfig` on the client, or pass `vectorStore` and `embedding` on one knowledge call.

## Client config

```js
import { DNotifier } from "@dnotifier-realtime/dnotifier";

const USER_ID = "user-123";

const notifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_SECRET,
  transport: "http",
  userId: USER_ID,
  serverConfig: {
    vectorStore: {
      provider: "weaviate",
      host: process.env.WEAVIATE_HOST || "http://127.0.0.1:8080",
      className: "RagChunk",
    },
    embedding: {
      provider: "ollama",
      baseUrl: process.env.OLLAMA_BASE_URL || "http://127.0.0.1:11434",
      model: "nomic-embed-text",
    },
  },
  onConnected: () => {},
  onMessage: () => {},
  onDisconnected: () => {},
});

await notifier.connect();

await notifier.addDocument({
  senderId: USER_ID,
  recordId: "refund-policy",
  content: "Refund requests are processed within 5 business days.",
  type: "text",
  metadata: { source: "help-center" },
});

const hits = await notifier.search({
  senderId: USER_ID,
  query: "how long do refunds take",
  limit: 5,
});
```

You can also assign it after construction. It applies to later calls on this instance:

```js
notifier.serverConfig = {
  vectorStore: { provider: "postgres" },
  embedding: { provider: "open_ai", model: "text-embedding-3-small", dimensions: 1536 },
};

notifier.serverConfig = null;
```

## Override one call

The Pinecone store is used for this search. The embedding you already set is still used.

```js
await notifier.search({
  senderId: USER_ID,
  query: "refund timeline",
  vectorStore: {
    provider: "pinecone",
    apiKey: process.env.PINECONE_API_KEY,
    host: process.env.PINECONE_HOST,
    namespace: "help-center",
  },
});
```

`vectorStoreConfig` and `embeddingConfig` are the same options. A `serverConfig` on the call applies to that call only:

```js
await notifier.deleteDocument({
  senderId: USER_ID,
  recordId: "refund-policy",
  serverConfig: {
    vectorStore: { provider: "qdrant", host: "https://qdrant.example" },
    embeddingConfig: { provider: "gemini", apiKey: process.env.GEMINI_API_KEY },
  },
});
```

The same fields work on `updateDocument`, `getDocument`, and `listDocuments`.

## Workflow context

`ctx.search` and the document helpers take the same options. `ctx.notifier.serverConfig` is used when the call leaves them out.

```js
const hits = await ctx.search({
  query: "refund policy",
  limit: 5,
  label: "FAQ search",
  vectorStore: { provider: "postgres" },
});
```

## Learn more

* [**Vector stores and embeddings**](https://dnotifier.gitbook.io/product-docs/ai/vector-stores.md) — providers, required fields, and defaults
* [**Semantic search**](https://dnotifier.gitbook.io/product-docs/ai/semantic-search/javascript-typescript.md)
* [**Manage documents**](https://dnotifier.gitbook.io/product-docs/ai/manage-documents/javascript-typescript.md)
