Quick Start Guide

Build your first app in 5 minutes

In this short guide, you'll learn key concepts and experience the Encore workflow. It should only take about 5 minutes to complete and by the end you'll have an API running in Encore's free development Cloud (Encore Cloud).

To make it easy to follow along, we've laid out a trail of croissants to guide your way. Whenever you see a 🥐 it means there's something for you to do.

Choose a language to get started.

1. Install the Encore CLI

To develop with Encore, you need the Encore CLI. It provisions your local environment, and runs your local development dashboard complete with tracing and API documentation.

🥐 Install by running the appropriate command for your system:

macOS
Windows
Linux
Brew
$ brew install encoredev/tap/encore

2. Create your app

🥐 Create your app by running:

$ encore app create

🥐 Continue by picking a name for your app and select the Hello World template.

If this is the first time you're using Encore, you'll be asked if you wish to create a free account. This is needed when you want Encore to manage functionality like secrets and handle cloud deployments (which we'll use later on in the tutorial).

Let's take a look at the code

Part of what makes Encore different is the simple developer experience when building distributed systems. Let's look at the code to better understand how to build applications with Encore.

🥐 Open the hello.ts file in your code editor. It's located in the folder: your-app-name/hello/.

You should see this:

import { api } from "encore.dev/api"; export const world = api( { method: "GET", path: "/hello/:name", expose: true }, async ({ name }: { name: string }): Promise<Response> => { return { message: `Hello ${name}!` }; }, ); interface Response { message: string; }

As you can see, it's all standard TypeScript.

You define an API endpoint by wrapping a regular async function in a call to api. Doing this makes Encore identify the world function as a public API endpoint. Encore automatically handles authentication, HTTP routing, request validation, error handling, observability, API documentation, and more.

The world endpoint is part of the hello service because in the same folder you will also find a file named encore.service.ts which looks like this:

import { Service } from "encore.dev/service"; export default new Service("hello");

This is how you define services with Encore. Encore will now consider files in the hello directory and all its subdirectories as part of the hello service. If you want to create more services, simply create a new folders, add a encore.service.ts file that is exporting a new Service. If you're curious, you can read more about defining services and APIs.

The Encore.ts Backend Framework provides several declarative ways of using backend primitives like databases, Pub/Sub, and scheduled tasks by simply writing code.

3. Start your app & Explore Local Development Dashboard

🥐 Now let's run your app locally:

$ cd your-app-name # replace with the app name you picked
$ encore run

You should see this:

That means your local development environment is up and running! Encore takes care of setting up all the necessary infrastructure for your applications, even including databases and Pub/Sub.

Open the Local Development Dashboard

You can now start using your Local Development Dashboard.

🥐 Open http://localhost:9400 in your browser to access it.

The Local Development Dashboard is a powerful tool to help you move faster when you're developing new features.

It comes with an API explorer, a Service Catalog with automatically generated documentation, and powerful observability features like distributed tracing.

Through the Local Development Dashboard you also have access to Encore Flow, a visual representation of your microservice architecture that updates in real-time as you develop your application.

Call your API

🥐 While you keep the app running, call your API from the API Explorer:

You can also open a separate terminal to call your API endpoint:

$ curl http://localhost:4000/hello/world
{"Message": "Hello, world!"}

If you see this JSON response, you've successfully made an API call to your very first Encore application. Well done, you're on your way!

Review a trace of the request

You can now take a look at the trace for the request you just made by clicking on it in the right column in the local dashboard.

With such a simple API, there's not much to it, just a simple request and response.

However, just imagine how powerful it is to have tracing when you're developing a more complex system with multiple services, Pub/Sub, and databases. (Learn more about Encore's tracing capabilities in the tracing docs.)

4. Push a code change and deploy

Let's put our mark on this API and make our first code change.

🥐 Head back to your code editor and look at the hello.ts file again. If you can't come up a creative change yourself, why not simply change the "Hello" message to a more sassy "Howdy"?

🥐 Once you've made your change, save the file.

When you save, the daemon run by the Encore CLI instantly detects the change and automatically recompiles your application and reloads your local development environment.

The output where you're running your app will look something like this:

Changes detected, recompiling... Reloaded successfully. INF registered endpoint endpoint=World path=/hello/:name service=hello INF listening for incoming HTTP requests

🥐 Test your change by calling your API again.

$ curl http://localhost:4000/hello/world
{"Message": "Howdy, world!"}

Great job, you made a change and your app was reloaded automatically.

Now you're ready to head to the cloud!

Deploy your app to the cloud

You can either deploy by following the self-hosting instructions to generate a Dockerfile.

Optionally, you can use Encore's Cloud Platform which comes with built-in free hosting and integrations to use your own cloud on AWS or GCP.

Since this is the first time you deploy an Encore app, we'll show you how simple it is using Encore's free development Cloud.

🥐 To deploy, simply push your changes to Encore:

$ git add -A .
$ git commit -m 'Initial commit'
$ git push encore

Encore's Cloud Platform will now build and test your app, provision the needed infrastructure, and deploy your application to a staging environment.

Your app will soon be running in the cloud, isn't this exciting?

5. Explore the Cloud Dashboard

After triggering the deployment, you will see a URL where you can view its progress in Encore's Cloud Dashboard. It will look something like: https://app.encore.dev/$APP_ID/deploys/...

🥐 Open the URL to access the Cloud Dashboard and check the progress of your deployment.

You can now use the Cloud Dashboard to view production logs and traces, create new environments, connect your cloud account, integrate with GitHub, and much more.

Call your API in the cloud

Now that you've created your staging environment, you're ready to call your API running in the cloud. Your API Base URL will be something like: https://staging-$APP_ID.encr.app

🥐 When the deploy is finished, call your API from the Cloud Dashboard using the API Explorer in the Service Catalog.

Or you can call it from the terminal (replacing $APP_ID with your own App ID):

$ curl https://staging-$APP_ID.encr.app/hello/world
{"Message": "Howdy, world!"}

If you see this, you've successfully made an API call to your very first Encore app running in the cloud.

Congratulations, you're well on your way to escaping the maze of cloud complexity!

What's next?

🥐 Check out the REST API tutorial to learn how to create endpoints, use databases, and more.

If you want to chat to other pioneering developers already building with Encore, or need help, join the friendly community on Discord.