DEV Community

Alex Spinov
Alex Spinov

Posted on

Nitric Has a Free API: Build Cloud-Agnostic Apps That Deploy to AWS, GCP, or Azure

Nitric is a cloud-agnostic framework that lets you define APIs, databases, queues, and storage in code — then deploy the same app to AWS, GCP, or Azure without changing a line.

Why Nitric Matters

Cloud lock-in is real. Your AWS Lambda functions cannot run on GCP Cloud Run. Your DynamoDB code cannot switch to Firestore. Nitric abstracts cloud services behind a unified API.

What you get for free:

  • Write once, deploy to AWS, GCP, or Azure
  • Declare resources in code: APIs, buckets, topics, schedules, secrets
  • Automatic IAM permissions (no YAML policies)
  • Local development with full emulation
  • TypeScript, Python, Go, Java, and Dart SDKs
  • Pulumi/Terraform under the hood — full IaC compatibility

Quick Start

# Install
curl -fsSL https://nitric.io/install | bash

# Create project
nitric new my-api ts-starter
cd my-api

# Run locally
nitric start

# Deploy to AWS
nitric up --target aws

# Deploy to GCP
nitric up --target gcp
Enter fullscreen mode Exit fullscreen mode

HTTP API

import { api } from "@nitric/sdk";

const mainApi = api("main");

mainApi.get("/users/:id", async (ctx) => {
  const { id } = ctx.req.params;
  const user = await getUser(id);
  ctx.res.json(user);
});

mainApi.post("/users", async (ctx) => {
  const body = ctx.req.json();
  const user = await createUser(body);
  ctx.res.status = 201;
  ctx.res.json(user);
});
Enter fullscreen mode Exit fullscreen mode

Cloud Storage (Any Provider)

import { bucket } from "@nitric/sdk";

// This becomes S3 on AWS, Cloud Storage on GCP, Blob Storage on Azure
const uploads = bucket("uploads").allow("read", "write", "delete");

// Upload
await uploads.file("reports/q1.pdf").write(pdfBuffer);

// Download
const data = await uploads.file("reports/q1.pdf").read();

// Generate signed URL
const url = await uploads.file("reports/q1.pdf").getDownloadUrl();

// List files
const files = await uploads.files();
for await (const file of files) {
  console.log(file.name);
}
Enter fullscreen mode Exit fullscreen mode

Pub/Sub (Any Provider)

import { topic } from "@nitric/sdk";

// Becomes SNS/SQS on AWS, Pub/Sub on GCP, Service Bus on Azure
const orders = topic("orders").allow("publish");

// Publish event
await orders.publish({ orderId: "123", total: 99.99, status: "new" });

// Subscribe
topic("orders").subscribe(async (ctx) => {
  const order = ctx.req.json();
  console.log(`Processing order ${order.orderId}`);
  await processOrder(order);
});
Enter fullscreen mode Exit fullscreen mode

Scheduled Tasks

import { schedule } from "@nitric/sdk";

schedule("cleanup").every("1 hour", async () => {
  await deleteExpiredSessions();
  console.log("Cleanup done");
});

schedule("daily-report").every("1 day", async () => {
  const report = await generateReport();
  await sendEmail(report);
});
Enter fullscreen mode Exit fullscreen mode

Secrets Management

import { secret } from "@nitric/sdk";

// Becomes AWS Secrets Manager, GCP Secret Manager, or Azure Key Vault
const apiKey = secret("api-key").allow("access");

const value = await apiKey.latest().access();
console.log(value.asString());
Enter fullscreen mode Exit fullscreen mode

Useful Links


Building multi-cloud data pipelines? Check out my developer tools on Apify for ready-made web scrapers, or email spinov001@gmail.com for custom solutions.

Top comments (0)