As developers, we often use databases like PostgreSQL, MySQL, or MongoDB when building backend applications with NestJS. But not every data problem needs a traditional database setup.
As developers, we often use databases like PostgreSQL, MySQL, or MongoDB when building backend applications with NestJS. But not every data problem needs a traditional database setup.
Recently, we started exploring DuckDB for analytical workloads and data processing. DuckDB is an in-process analytical database that is lightweight, fast, and easy to work with.
While using DuckDB with a NestJS application, we wanted a simple integration that felt natural within the NestJS ecosystem.
So, we created nestjs-duckdb
Please check the complete documentation here: nestjs-duckdb Doc
DuckDB is an analytical database designed to run directly inside your application. Unlike traditional databases that require a separate database server, DuckDB can run in-process.
This makes it an interesting option for use cases such as:
Data analytics
Reporting
Data processing
Local data exploration
ETL workflows
Analytical workloads
It also supports both in-memory databases and database files, giving developers flexibility depending on their use case.
Why Did We Create nestjs-duckdb?
When working with DuckDB in a NestJS application, we wanted to keep the integration simple.
We didn't want developers to deal with unnecessary configuration or write repetitive database initialization code.
We wanted something that followed the familiar NestJS module and dependency injection patterns:
DuckDbModule.forRoot({
database: ':memory:',
});
Then, wherever we need DuckDB, we can simply inject the service:
constructor(
private readonly duckDb: DuckDbService,
) {}
From there, you can run your queries and work with DuckDB directly from your NestJS services.
That's the main idea behind nestjs-duckdb
Keep it simple. Configure it once. Inject it wherever you need it.
What Does the Package Provide?
The package provides a simple integration layer between NestJS and DuckDB.
It supports:
Easy DuckDB configuration with
forRoot()Asynchronous configuration with
forRootAsync()Dependency injection through
DuckDbServiceRunning SQL queries
Running SQL statements
Access to the underlying DuckDB connection
Access to the raw DuckDB database
Direct database injection when lower-level access is required
The API is intentionally small. The goal is not to hide DuckDB behind a complicated abstraction, but to make it easier to use within a NestJS application.
A Quick Example
After installing the package:
npm install nestjs-duckdb
You can configure it in your NestJS module:
import { Module } from '@nestjs/common';
import { DuckDbModule } from 'nestjs-duckdb';
@Module({
imports: [
DuckDbModule.forRoot({
database: ':memory:',
}),
],
})
export class AppModule {}
Then inject DuckDbService into your application services and start working with your data.
For more detailed usage, configuration options, and examples, check out the package documentation and README.
Who Is It For?
nestjs-duckdb can be useful for developers building NestJS applications that need to work with DuckDB for analytical or data-processing use cases.
For example, you might be building:
An internal analytics service
A reporting application
A data processing tool
An ETL pipeline
A service that needs to process local datasets
A lightweight analytical backend
Of course, whether DuckDB is the right choice depends on your specific architecture and workload. But if you're already using NestJS and want to explore DuckDB, we hope this package makes the experience a little easier.
Built for the NestJS Community
We created Nestjs DuckDB because we wanted a straightforward way to bring DuckDB into NestJS projects.
It's a small package with a simple goal: make DuckDB feel at home in a NestJS application.
If you're interested in trying it out, check out the documentation and examples in the package repository.
We'd love to hear your feedback, suggestions, and ideas for improving the package.
Have a NestJS project that uses DuckDB? Please check the complete Documentation here nestjs-duckdb a try and let us know what you think!


