Examples of using YDB JS SDK with popular backend frameworks and libraries.
This repository contains basic examples demonstrating how to use the latest YDB JS SDK (@ydbjs/core, @ydbjs/query) with various backend frameworks:
- Express - Example with Express.js framework
- Fastify - Example with Fastify framework
- NestJS - Example with NestJS framework
- Hono - Example with Hono framework
- Bun - Example with Bun runtime
- Express (CommonJS) - Express.js example using CommonJS
- NestJS (CommonJS) - NestJS example using CommonJS
Each example demonstrates:
- Initializing YDB driver with
@ydbjs/core - Executing simple queries with
@ydbjs/query - Graceful shutdown handling
- Basic health check and query endpoints
The easiest way to start YDB locally is using Docker:
docker run -d --rm --name ydb-local -h localhost \
-p 2135:2135 -p 2136:2136 -p 8765:8765 \
-e GRPC_TLS_PORT=2135 -e GRPC_PORT=2136 -e MON_PORT=8765 \
ydbplatform/local-ydb:latestThis will start YDB with:
- gRPC endpoint at
grpc://localhost:2136 - Database path
/local - Web UI at
http://localhost:8765
To stop YDB:
docker stop ydb-localFor more information, see the YDB Docker documentation.
- Start YDB (see Prerequisites above)
- Choose a framework example directory
- Install dependencies:
npm install - Run the example:
npm start
All examples use the following environment variables:
YDB_CONNECTION_STRING- YDB connection string (default:grpc://localhost:2136/local)PORT- Server port (default:3000)