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:

RequirementNotes
Stable Rust + CargoInstall from rustup.rs
GitAny recent version
protocOnly 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:

FeatureWhat it adds
openapi#[summary], #[tag], #[response] macros + docs mounting helpers
configConfigModule, EnvSchema, load_config() for typed env config
dbDb, connect_db() for SQL via sqlx
ormRepo, SqlRepo, EntityMeta on top of db
graphqlgraphql_router, GraphQlConfig, async_graphql re-export
grpcNestForgeGrpcFactory, GrpcContext, prost/tonic re-export
websocketswebsocket_router, WebSocketGateway, Message types
microservicesMicroserviceRegistry, InProcessMicroserviceClient
scheduleScheduleRegistry, ScheduledJob, start_schedules(), shutdown_schedules()
cacheCacheInterceptor, CachePolicy, cached_response_interceptor
mongoInMemoryMongoRepo, MongoConfig
redisInMemoryRedisStore, RedisConfig
testingTestFactory, TestingModule for integration tests
dataBase 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.