Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/khode-io/nest-dart/llms.txt

Use this file to discover all available pages before exploring further.

Nest Dart

A NestJS-inspired dependency injection framework for Dart, bringing modular architecture and type-safe service management to Dart applications.

What is Nest Dart?

Nest Dart is a powerful framework that brings the elegant architecture patterns of NestJS to the Dart ecosystem. It provides a robust dependency injection system with module-based organization, making it easy to build scalable applications across Flutter, Dart Frog, and pure Dart platforms.

Quick start

Get up and running with Nest Dart in minutes

Core concepts

Learn about modules, services, and dependency injection

Flutter integration

Build Flutter apps with modular architecture

Dart Frog integration

Create backend APIs with dependency injection

Key features

Modular architecture

Organize code into reusable, self-contained modules that encapsulate related functionality

Dependency injection

Type-safe service resolution with GetIt, providing compile-time safety and runtime efficiency

Access control

Services are private by default and must be explicitly exported, ensuring clear module boundaries

Multi-platform support

Works seamlessly with Flutter, Dart Frog, and pure Dart applications

Module-based routing

GoRouter integration with automatic route collection from modules

Lifecycle management

Module initialization and cleanup hooks for resource management

Basic example

Here’s a simple example showing how to create a module with dependency injection:
import 'package:nest_core/nest_core.dart';

class AppModule extends Module {
  @override
  List<Module> get imports => [CoreModule(), UserModule()];
  
  @override
  void providers(Locator locator) {
    locator.registerSingleton<UserService>(UserService());
  }
  
  @override
  List<Type> get exports => [UserService];
}

// Initialize the application
final container = ApplicationContainer();
await container.registerModule(AppModule());

Platform integrations

Nest Dart provides specialized packages for different platforms:

Flutter

Build mobile and web applications with modular architecture:
import 'package:flutter/material.dart';
import 'package:nest_flutter/nest_flutter.dart';

void main() {
  runApp(
    ModularApp(
      module: AppModule(),
      child: MyApp(),
    ),
  );
}

Dart Frog

Create backend APIs with dependency injection:
import 'package:dart_frog/dart_frog.dart';
import 'package:nest_frog/nest_frog.dart';

Handler middleware(Handler handler) {
  return handler.use(nestFrogMiddleware(AppModule()));
}

Packages

Nest Dart consists of three main packages:

nest_core

Core dependency injection and module system

nest_flutter

Flutter integration with GoRouter and provider support

nest_frog

Dart Frog backend integration with middleware support

Why Nest Dart?

Nest Dart brings the proven architectural patterns from the backend world to Dart, making it easier to build maintainable and scalable applications.
  • Type safety - Leverage Dart’s strong type system with compile-time dependency resolution
  • Familiar patterns - If you know NestJS, you’ll feel right at home
  • Testability - Module-based architecture makes testing and mocking straightforward
  • Flexibility - Use it with Flutter, Dart Frog, or standalone Dart applications
  • Performance - Built on GetIt for efficient service resolution with minimal overhead

Next steps

1

Install Nest Dart

Follow the installation guide to add Nest Dart to your project
2

Complete the quickstart

Build your first Nest Dart application with our quickstart guide
3

Explore core concepts

Learn about modules, providers, and dependency injection in the core concepts section

Build docs developers (and LLMs) love