Nitric Documentation
Build cloud backends that run anywhere, fast.
Nitric is a cloud framework with common resources like APIs, websockets, databases, queues, topics, buckets, and more.
However, Nitric is unique - it doesn't just deploy the resources, it helps you interact with them. It also makes them pluggable, so you can swap services or even whole clouds without changing your code.
It's what's missing between applications and infrastructure automation.
Oh, and it supports basically any language, like JavaScript, TypeScript, Python, Go, you name it.
Services
Services are the heart of Nitric apps, they're the entrypoints to your code. They can serve as APIs, websockets, schedule handlers, subscribers and a lot more. You create services by telling Nitric where to look for your code and how to run it.
name: example
services:
- match: services/*.ts
start: npm run dev:services $SERVICE_PATH
You might have one service that handles everything, or a service for each route. It's up to you.
Resources
Resources are the building blocks of your apps. They're the databases, queues, buckets, etc. that your services interact with. If you want a resource, you just ask for it.
import { bucket } from '@nitric/sdk'
const profiles = bucket('profiles').allow('read', 'write', 'delete')
Nitric collects everything your services request. When you deploy, the deployment plugin you choose creates the resources and services, then links it all together.
That probably sounds like magic, but it's more like a compiler for Infrastructure-as-Code - you can read about it in the Concepts section.
Providers
Nitric is designed to be independent of any platform, so you can run your apps anywhere. You can deploy to AWS, Azure, GCP, or even your own Kubernetes cluster. You can even deploy to multiple clouds at once.
Seriously, is there really a difference between a bucket on AWS and a bucket on Azure? We don't think so. So why should the code be different?
Nitric abstracts away the differences, so you can focus on your app. The part that makes that possible is a plugin, we call a Provider.
provider: nitric/aws@1.1.1
region: us-east-1
We have a few providers built-in with IaC from Pulumi or Terraform, but you can build your own with any tools you prefer and to anywhere you want. You can even deploy to multiple clouds at once.
Projects
Projects built with Nitric don't have many restrictions. You can use most languages, most libraries, most tools, most clouds, most services, mostly anything you like. But, you need to have a nitric.yaml
file in the root of your project.
name: example
services:
- match: services/*.ts
start: npm run dev:services $SERVICE_PATH
Nitric uses this to find your services, then it turns each service into a container, runs them in deployment mode to match the resources you requested and gives the result to the Provider - which either generates IaC (like Terraform) or automatically deploys your app.
So, a project structure might look something like this:
example/
โโโ nitric.yaml
โโโ services/
โ โโโ orders.ts
โ โโโ users.ts
โโโ package.json
CLI
Nitric has a CLI to help you create, manage, run and deploy your projects. We recommend installing it with a package manager:
brew install nitrictech/tap/nitric
New
You can create a new project from a template with the new
command.
nitric new
Start
You can run your project locally with the start
command.
nitric start
Start also emulates the resources you requested, so you can test your app locally. And provides a Dashboard UI to interact with the resources.
Deploy
You can deploy your project with the up
command, once you have a stack file (deployment target).
nitric stack new
nitric up
Some providers don't deploy directly, instead they generate IaC files. In those cases you use the IaC tool to deploy (e.g. terraform apply
).
Tear Down
You can tear down your project with the down
command.
nitric down
Dashboard
Nitric has a local Dashboard UI (hosted by the CLI) to help you interact with your resources. You can typically access it at http://localhost:49152.
What now?
If you're still not sure what to make of Nitric, maybe start with the Concepts section, otherwise the best way to learn is to dive into the Guides and start building your first project.