1. Create a new Encore app


In this tutorial you will create your very first Encore application, and deploy it to production using the Encore platform.

1.1 Make sure Encore is installed

If you haven't already done so, install Encore. If you're not sure, run encore version in your terminal. It should print something like:

encore version v1.0.0

1.2 Make sure Docker is installed and running

To create Encore applications with databases, you need Docker installed and running. If you haven't already, install Docker before proceeding.

1.3 Create a new app

Once you've installed Encore, creating an app is easy, simply run:

encore app create

Then pick a name for your app using lowercase letters, digits, or dashes.

Then choose between two example applications Hello World and Trello Clone, or creating an Empty app.

Once created, take a note of its App ID. This will be something like hello-world-4x3b (yours will be different).

1.4 Running your app

To run your app, open the folder created for your application. (Note: Your App ID will be different)

cd hello-world-4x3b

Then while in the app root directory, run your app by simply running:

encore run

You should see this:

$ encore run
Running on http://localhost:4060
9:00AM INF registered endpoint endpoint=World service=hello

That means your application is up and running!

While you keep the app running, open a separate terminal and call your API endpoint:

$ curl http://localhost:4060/hello.World
{"Message": "Hello, world!"}

If you see this message, you've successfully created and run your first Encore application. Well done!

1.5 Open the Encore web application

While running your app, you can monitor local logs and traces by opening http://localhost:4060 in your browser.

Now head to the Encore web application where you can see production logs and traces, manage environments and configure your cloud hosting.

1.6 Your first API

If you started with the `Empty app`, here are instructions for how you create your first API. If you picked `Hello World`, this will already be set up in your app.

For an app to be useful, it must have an API. Each API belongs to a service. Start by creating a new directory named hello in your app root directory. This which will be your service package. Then, create a file named hello.go inside:

$ cd myapp
$ mkdir hello
$ touch hello/hello.go

Open up the hello.go file and add the following contents:

package hello

import "context"

type Response struct {
    Message string
}

//encore:api public
func World(ctx context.Context) (*Response, error) {
    return &Response{Message: "Hello, world!"}, nil
}