Defining Services

Simplifying (micro-)service development

Encore.ts makes it simple to build applications with one or many services, without needing to manually handle the typical complexity of developing microservices.

Defining services

To create an Encore service, add a file named encore.service.ts in a directory.

The file must export a service instance, by calling new Service, imported from encore.dev/service.

For example:

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

That's it! Encore will consider this directory and all its subdirectories as part of the service.

With multiple services, each service lives in its own directory with its own encore.service.ts:

/my-app ├── package.json ├── encore.app │ ├── hello // hello service │ ├── encore.service.ts │ └── hello.ts │ └── world // world service ├── encore.service.ts └── world.ts

For more on how to structure your application, see the app structure guide.