2 · Create a project

nyx init scaffolds a project: a nyx.toml manifest and a src/main.nx entry point. We add one line to declare the framework as a dependency.

$ nyx init notes-app
$ cd notes-app

Declare the dependency

Open nyx.toml and add nyx-serve under [dependencies]:

# nyx.toml
[package]
name = "notes-app"
version = "0.1.0"
main = "src/main.nx"

[dependencies]
nyx-serve = "*"

"*" tells the package manager to fetch nyx-serve from github.com/nyxlang-dev/nyx-serve into packages/ on the next build. You can also pin a full URL — nyx-serve = "https://github.com/nyxlang-dev/nyx-serve" — or vendor the library into packages/ and commit it, which is what production sites do for reproducible builds.

A minimal server

Replace src/main.nx with:

import "std/web"
import "nyx-serve/src/server"

fn home(req: Request) -> Response {
    return response_html(200, "<h1>notes-app</h1>")
}

fn main() {
    let app: App = app_new()
    app_get(app, "/", home)
    serve_app(app, 3000, 8)
}

The three moving parts, from the imports:

Build and run

$ nyx run
notes-app starting on port 3000 with 8 workers

In another terminal:

$ curl http://localhost:3000/
<h1>notes-app</h1>
nyx run builds then runs. nyx build just produces the binary (named after your package) — that single file is what you copy to a server.