SST vs. Nitric

Nitric is a framework designed to aid developers in building full cloud applications on the Cloud of their choice, including declaring their infrastructure and application code in one place. SST is a framework that makes it easy to build modern full-stack JavaScript/TypeScript applications on AWS.

These are the main differences between the two:

  1. Cloud Provider Support: Nitric is provider-agnostic, capable of deploying to multiple cloud providers such as AWS, Google Cloud, and Azure. SST is primarily designed for AWS services.
  2. Language Support: Nitric provides multiple libraries for TypeScript/JavaScript, Python, Go, C# .NET and Java, allowing developers to choose their preferred language. Currently SST only supports TypeScript and JavaScript.
  3. Infrastructure Provisioning: Nitric uses Pulumi by default for provisioning cloud resources, but also allows the use of custom providers. SST uses the AWS CDK, which uses AWS CloudFormation for provisioning.
  4. Local Simulation: Nitric provides a fully offline local cloud simulation tool, allowing you to test your applications locally before deploying them. This is a feature that SST does not offer, for local development SST deploys your application to the cloud and uses a proxy to sync with your local code.

Code Comparison

To get a deeper understanding of the differences, let's see the same app built in both Nitric and SST. The SST App in this example is standalone without the frontend code.

Nitric

import { api } from '@nitric/sdk'
const helloApi = api('main')
helloApi.get('/hello/:name', async (ctx) => {
const { name } = ctx.req.params
ctx.res.body = `Hello ${name}`
})

SST

import { ApiHandler, usePathParam } from 'sst/node/api'
export const handler = ApiHandler(async (evt) => {
const name = usePathParam('name')
return {
statusCode: 200,
body: `Hello ${name}`,
}
})
import { StackContext, Api } from 'sst/constructs'
export function API({ stack }: StackContext) {
const api = new Api(stack, 'api', {
routes: {
'GET /hello/{name}': 'packages/functions/src/hello.handler',
},
})
stack.addOutputs({
ApiEndpoint: api.url,
})
}

One key difference between Nitric and SST examples is while Nitric allows defining the API route handler inline which streamlines and simplifies the code, SST separates the route definition and the handler into different files for modularity. Another difference is that Nitric is cloud-neutral while SST is designed specifically for AWS.

Differences

NitricSST
LanguageYour choiceJavaScript / TypeScript
Lines of code923
Cloud InfrastructureInferredExplicit
ExtensibilityCustom providers can be createdYes, you can fallback to using the underlying AWS CDK constructs.
Local simulationBuilt-in local simulator with instant hot reloading and offline supportNo, provides proxy to a deployed app
Cloud providersAWS, Azure, GCP and Custom providersAWS
Provisioning enginePulumi by default, other custom providers can be createdCloudFormation via AWS CDK (CDKTF is used for Terraform, but you cannot compile the same code to different engines)
Last updated on Dec 19, 2024