[**@lancedb/lancedb**](../README.md) • **Docs** *** [@lancedb/lancedb](../globals.md) / connectNamespace # Function: connectNamespace() ## connectNamespace(implName, config, options) ```ts function connectNamespace( implName, config, options?): Promise ``` Connect to a LanceDB database through a namespace. Unlike [connect](connect.md), which routes by URI scheme (local path vs. `db://` cloud), `connectNamespace` always returns a namespace-backed connection. The `implName` selects the namespace implementation: - `"dir"` — directory namespace, configured with [DirNamespaceConfig](../interfaces/DirNamespaceConfig.md). - `"rest"` — remote REST catalog, configured with [RestNamespaceConfig](../interfaces/RestNamespaceConfig.md). - Any other string — full module path for a custom implementation, configured with a free-form string-keyed `properties` map. ### Parameters * **implName**: `"dir"` * **config**: [`DirNamespaceConfig`](../interfaces/DirNamespaceConfig.md) * **options?**: `Partial`<[`ConnectNamespaceOptions`](../interfaces/ConnectNamespaceOptions.md)> ### Returns `Promise`<[`Connection`](../classes/Connection.md)> ### Examples ```ts const db = await connectNamespace("dir", { root: "/path/to/db" }); await db.createTable("users", [{ id: 1 }]); ``` ```ts const db = await connectNamespace("rest", { uri: "https://catalog.example.com", headers: { "x-api-key": process.env.CATALOG_KEY ?? "" }, }); ``` ```ts const db = await connectNamespace("my.custom.Namespace", { endpoint: "...", }); ``` ## connectNamespace(implName, config, options) ```ts function connectNamespace( implName, config, options?): Promise ``` Connect through the built-in REST namespace. Configured with [RestNamespaceConfig](../interfaces/RestNamespaceConfig.md). See the function-level documentation above for the full surface, examples, and how this relates to [connect](connect.md). ### Parameters * **implName**: `"rest"` * **config**: [`RestNamespaceConfig`](../interfaces/RestNamespaceConfig.md) * **options?**: `Partial`<[`ConnectNamespaceOptions`](../interfaces/ConnectNamespaceOptions.md)> ### Returns `Promise`<[`Connection`](../classes/Connection.md)> ### Example ```ts const db = await connectNamespace("rest", { uri: "https://catalog.example.com", headers: { "x-api-key": process.env.CATALOG_KEY ?? "" }, }); ``` ## connectNamespace(implName, properties, options) ```ts function connectNamespace( implName, properties, options?): Promise ``` Connect through a custom namespace implementation by full module path, configured with a free-form string-keyed `properties` map. Use the typed overloads above for the built-in `"dir"` and `"rest"` impls. See the function-level documentation above for examples and how this relates to [connect](connect.md). ### Parameters * **implName**: `string` * **properties**: `Record`<`string`, `string`> * **options?**: `Partial`<[`ConnectNamespaceOptions`](../interfaces/ConnectNamespaceOptions.md)> ### Returns `Promise`<[`Connection`](../classes/Connection.md)> ### Example ```ts const db = await connectNamespace("my.custom.Namespace", { endpoint: "...", }); ```