Skip to content

Installation

Install the NestForge CLI, set up your Rust project, and choose the features your application needs.

This page covers everything needed to go from zero to a running NestForge application.

Before you start, make sure you have:

Requirement Notes
Stable Rust + Cargo Install from rustup.rs
Git Any recent version
protoc Only required if you use the gRPC feature

Check your Rust version with:

Terminal window
rustc --version
# rustc 1.75.0 (or later)

Install the NestForge CLI from crates.io:

Terminal window
cargo install nestforge-cli

Verify the install worked:

Terminal window
nestforge --version

Scaffold a new HTTP application:

Terminal window
nestforge new my-api
cd my-api

The generator creates the application bootstrap files at the root of src/:

my-api/
Cargo.toml
.env
.env.example
src/
main.rs
app_config.rs
app_controller.rs
app_service.rs
app_module.rs
health_controller.rs

Feature folders such as src/users/ are generated later when you add modules or resources.

Run it right away:

Terminal window
cargo run

The server starts on http://127.0.0.1:3000 by default.


The generated Cargo.toml starts with only the core dependency:

[dependencies]
nestforge = { version = "1", features = [] }
tokio = { version = "1", features = ["full"] }
anyhow = "1"
axum = "0.7"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

NestForge is feature-gated. You only compile and link what you need.


Enable features by adding them to your Cargo.toml:

[dependencies]
nestforge = { version = "1", features = ["openapi"] }

Here is the full feature reference:

Feature What it adds
openapi #[summary], #[tag], #[response] macros + docs mounting helpers
config ConfigModule, EnvSchema, load_config() for typed env config
db Db, connect_db() for SQL via sqlx
orm Repo, SqlRepo, EntityMeta on top of db
graphql graphql_router, GraphQlConfig, async_graphql re-export
grpc NestForgeGrpcFactory, GrpcContext, prost/tonic re-export
websockets websocket_router, WebSocketGateway, Message types
microservices MicroserviceRegistry, InProcessMicroserviceClient
schedule ScheduleRegistry, ScheduledJob, start_schedules(), shutdown_schedules()
cache CacheInterceptor, CachePolicy, cached_response_interceptor
mongo InMemoryMongoRepo, MongoConfig
redis InMemoryRedisStore, RedisConfig
testing TestFactory, TestingModule for integration tests
data Base data-layer trait; pulled in by cache, mongo, and redis
# REST API with OpenAPI docs
nestforge = { version = "1", features = ["openapi", "config"] }
# REST API with a SQL database
nestforge = { version = "1", features = ["db", "orm", "openapi", "config"] }
# GraphQL API
nestforge = { version = "1", features = ["graphql", "config"] }
# Full-stack transport app
nestforge = { version = "1", features = ["openapi", "graphql", "websockets", "schedule", "config"] }

Terminal window
cargo check

You should see no errors. If you see E0433 for unresolved items from nestforge, you likely need to add the corresponding feature flag.