Encore vs. Nitric

Nitric is a framework that empowers developers to build complete cloud applications on their preferred cloud platform, combining infrastructure declaration and application code in one place. On the other hand, Encore is a development platform tailored for building cloud backend applications using the Go language, with deployment options for AWS or Google Cloud Platform. Both serve the purpose of simplifying cloud application development but operate in slightly different ways and cater to different specific needs. 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. Encore currently deploys to AWS or Google Cloud.
  2. Language Support: Nitric provides libraries for TypeScript/JavaScript, Python, Go, C# .NET and Java, allowing developers to choose their preferred language. Currently Encore supports Go, with TypeScript scheduled for Preview.
  3. Infrastructure Provisioning: Nitric uses Pulumi by default for provisioning cloud resources, but also allows the use of custom providers. Encore uses a hosted provisioning engine via their online platform.
  4. Open Source: As an open-source framework, Nitric does not require a platform or subscription to deploy applications, while Encore requires sign-up and may involve additional costs.

Code Comparison

To get a deeper understanding of the differences, let's see the same app built in both Nitric and Encore.

Nitric

services/hello/main.go
package main

import (
	"fmt"

	"github.com/nitrictech/go-sdk/faas"
	"github.com/nitrictech/go-sdk/nitric"
)

func main() {
	mainApi, err := nitric.NewApi("main")
	if err != nil {
		fmt.Println(err)
		return
	}

	mainApi.Get("/hello/:name", func(ctx *faas.HttpContext, next faas.HttpHandler) (*faas.HttpContext, error) {
		params := ctx.Request.PathParams()

		ctx.Response.Body = []byte("Hello " + params["name"])

		return next(ctx)
	})

	if err := nitric.Run(); err != nil {
		fmt.Println(err)
	}
}

Encore

hello.go
package hello

import (
	"context"
)

//encore:api public path=/hello/:name
func Hello(ctx context.Context, name string) (*Response, error) {
	msg := "Hello " + name
	return &Response{Message: msg}, nil
}

type Response struct {
	Message string
}

The Nitric example shows an API where HTTP request handling is achieved using faas.HttpContext, providing control over the request and response objects. The Encore example demonstrates an API where HTTP request handling is reflected through the function parameters and return types, with defined structs for responses.

Differences

NitricEncore
LanguageYour choiceGo
Lines of code2715
Cloud InfrastructureInferredInferred
ExtensibilityCustom providers can be createdNo
Local simulationBuilt-in local simulatorBuilt-in local simulator
Cloud providersAWS, Azure, GCP and Custom providersAWS and GCP
Provisioning enginePulumi by default, other custom providers can be createdHosted provisioning engine