The @ydbjs/core package provides the core driver and connection management for YDB in JavaScript/TypeScript. It is the foundation for all YDB client operations, handling connection pooling, service client creation, authentication, and middleware.
- Connection pooling and load balancing for YDB endpoints
- Service client creation for any YDB gRPC API
- Pluggable authentication via
@ydbjs/authproviders - Automatic endpoint discovery and failover
- TypeScript support with type definitions
- Compatible with Node.js and modern runtimes
npm install @ydbjs/core- Driver: The main entry point. Manages connections, endpoint discovery, and authentication.
- Connection Pool: Maintains and balances gRPC channels to YDB endpoints.
- Service Clients: Use
driver.createClient(ServiceDefinition)to get a typed client for any YDB gRPC service (from@ydbjs/api). - Authentication: Pass a credentials provider from
@ydbjs/authto the driver for static, token, anonymous, or cloud metadata authentication. - Middleware: Internal middleware handles metadata, authentication, and debugging.
import { Driver } from '@ydbjs/core'
import { DiscoveryServiceDefinition } from '@ydbjs/api/discovery'
const driver = new Driver('grpc://localhost:2136/local')
await driver.ready()
const discovery = driver.createClient(DiscoveryServiceDefinition)
const endpoints = await discovery.listEndpoints({ database: '/local' })
console.log(endpoints)
await driver.close()import { Driver } from '@ydbjs/core'
import { StaticCredentialsProvider } from '@ydbjs/auth/static'
const driver = new Driver('grpc://localhost:2136/local', {
credentialsProvider: new StaticCredentialsProvider({
username: 'user',
password: 'pass',
}),
})
await driver.ready()
// ...You can also use AccessTokenCredentialsProvider, AnonymousCredentialsProvider, or MetadataCredentialsProvider from @ydbjs/auth.
Always close the driver when done to release resources:
driver.close()npm run buildnpm testFor watch mode during development:
npm run test:watchThis project is licensed under the Apache 2.0 License.