Skip to content

ydb-platform/ydb-js-examples

Repository files navigation

YDB JS SDK Examples

Examples of using YDB JS SDK with popular backend frameworks and libraries.

Available Examples

This repository contains basic examples demonstrating how to use the latest YDB JS SDK (@ydbjs/core, @ydbjs/query) with various backend frameworks:

ESM (ES Modules)

  • 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

CommonJS

What's Inside

Each example demonstrates:

  • Initializing YDB driver with @ydbjs/core
  • Executing simple queries with @ydbjs/query
  • Graceful shutdown handling
  • Basic health check and query endpoints

Prerequisites

Starting YDB

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:latest

This 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-local

For more information, see the YDB Docker documentation.

Quick Start

  1. Start YDB (see Prerequisites above)
  2. Choose a framework example directory
  3. Install dependencies: npm install
  4. Run the example: npm start

Configuration

All examples use the following environment variables:

  • YDB_CONNECTION_STRING - YDB connection string (default: grpc://localhost:2136/local)
  • PORT - Server port (default: 3000)

Learn More

About

Examples of using ydb js sdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •