Quick Start Guide

Get started building with Encore in minutes

In this short guide, you'll learn Encore's 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 the cloud.

To make it easier 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.

Let's get started!

1. Install CLI & Create account

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

πŸ₯ Install the Encore CLI by running the appropriate command for your system:

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

Since this is the first time you're using Encore, you need to create an account and authenticate via the CLI. This is needed so that the Encore platform can orchestrate functionality like tracing, secrets, and manage cloud deployments.

You can use your account with GitHub, Google, or create an account using your email.

πŸ₯ Create an account and authenticate by running:

$ encore auth signup

2. Create your app

When you're building with Encore, it’s best to use one application for an entire project.

πŸ₯ Create your app by running:

$ encore app create

Continue by picking a name for your app, using lowercase letters, digits, or dashes.

Then select the Hello World template.

This will create an example application, with a simple REST API, in a new folder using the app name you picked.

Let's take a look at the code

A big part of what makes Encore different is the developer experience when you're writing code. Let's look at the code to better understand how to build applications with Encore.

πŸ₯ Open the hello.go file in your code editor. It's located in the folder: your-app-name/hello/.

You should see this:

package hello import ( "context" ) // This is a simple REST API that responds with a personalized greeting. // //encore:api public path=/hello/:name func World(ctx context.Context, name string) (*Response, error) { msg := "Hello, " + name + "!" return &Response{Message: msg}, nil } type Response struct { Message string }

As you can see, it's all standard Go code except for a few lines specific to Encore's infrastructure SDK.

One such element is the API annotation:

//encore:api public path=/hello/:name

This annotation is all that's needed for Encore to understand that this Go package is a service, hello, and that the World function is a public API endpoint.

If you want to create more services and endpoints, it's as easy as creating more Go packages and defining endpoints using the //encore:api annotation. If you're curious, you can read more about defining services and APIs.

Encore includes a few more native concepts that we'll begin to cover in the next tutorial, which for instance let you use backend primitives like databases and scheduled tasks by simply writing code.

Explore Encore

Making it easy to define APIs isn't the only thing Encore does to make your developer experience better. Encore integrates your entire workflow, from writing code to running in production.

πŸ₯ Now, let's run your application locally:

$ cd you-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, including databases.

πŸ₯ While you keep the app running, open a separate terminal and 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!

Your local development dashboard

You can now start using your local development dashboard.

πŸ₯ Open http://localhost:4000 in your browser to access it.

Your development dashboard is a powerful tool to help you move faster when you're developing new features.

It comes with an API explorer with automatically generated documentation, and powerful oberservability features like distributed tracing. Did we mention Encore automatically instruments your entire application with logs and tracing?

Through the development dashboard you also have access to Encore Flow which is a visual representation of your microservice architecture that updates in real-time as you develop your application.

In this short video you can see the development dashboard in use, showing the incident management tutorial application.

3. 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.go 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, Encore 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 in a separate terminal:

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

Great job, you're now ready to head to the cloud!

Deploy your app to the cloud

Remember we said Encore integrates your entire workflow? Let's try it out!

The first time you deploy, Encore will by default create a staging environment in Encore's cloud, running on Google Cloud Platform. This is free to use for development and hobby projects.

When you're ready, you can deploy to your own cloud using your own cloud account with GCP/AWS/Azure. Or even all of them – Encore makes it seamless to deploy to multiple cloud environments all at once.

πŸ₯ Now let's head to the cloud! Push your changes and deploy your application by running:

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

Encore will now build and test your app, provision the needed infrastructure, and deploy your application to the cloud.

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

Head to the web platform

After triggering the deployment, you will see a url where you can view its progress in the Encore web platform. It will look something like: https://app.encore.dev/$APP_ID/deploys/...

πŸ₯ Open the url to access the web platform and check the progress of your deployment.

You can now use the web platform to view production logs and traces, create new environments, connect the cloud account of your choice, 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 deployment is finished, call your API 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 Uptime Monitor tutorial to learn how to add more services, use databases, PubSub, and cron jobs.

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