How do I create my first ArkTS app in DevEco Studio?
Short answer: In DevEco Studio, create a new project with the Application > Empty Ability template, open entry/src/main/ets/pages/Index.ets, and click Run after selecting a device or emulator. The template already contains a working Hello World page written in ArkTS and ArkUI.
What do you need first?
- DevEco Studio, installed. See How to install DevEco Studio.
- A target: an emulator, or a connected device with developer mode enabled.
How do I create the project?
- Open DevEco Studio and create a new project.
- Select Application, then the Empty Ability template.
- Fill in the project fields: project name, Bundle name (the defaults are fine for a first app), Compatible SDK (for example
5.0.0(12)) and the model, Stage. - Finish and wait for the project to sync.
Note: since DevEco Studio 4.1 Beta1, a new project is created for HarmonyOS by default. To target OpenHarmony, change the project-level build-profile.json5:
"compileSdkVersion": 12,
"compatibleSdkVersion": 12,
"runtimeOS": "OpenHarmony"
What is in the project directory?
| Path | Purpose |
|---|---|
AppScope/app.json5 | Application-level configuration |
entry/src/main/ets/entryability | The application entry point |
entry/src/main/ets/pages | Page files, such as Index.ets |
entry/src/main/resources | Images, media, strings and layout resources |
entry/src/main/module.json5 | Module configuration |
entry/build-profile.json5 | Module build options |
oh_modules | Installed dependencies |
hvigorfile.ts | Build script |
What does Index.ets contain?
The template creates a page with a text and a button that navigates to a second page. The simplest version of it is:
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
@Entry makes this page an entry, @Component declares a UI component, @State makes message reactive and build() describes the UI. Change 'Hello World' to your own text and run again to see the update. Details: What is ArkTS?.
How do I run the app?
- Connect a device (or start the emulator). To check that the device is visible, see the hdc command guide.
- For a physical device, enable automatic signing in File > Project Structure > SigningConfigs.
- Select the device in the toolbar and click the Run button.
Menu names can change between DevEco Studio versions, so use the official tutorial if a menu looks different.
Next steps
Frequently asked questions
Which project template should I choose for a first app?
Choose Application and then the Empty Ability template. This creates a Stage model project with a single page, Index.ets.
What is the Stage model?
The Stage model is the current application model used in DevEco Studio projects. Its entry point is in src/main/ets/entryability and its pages are in src/main/ets/pages.
Where is the app code?
Page code is in entry/src/main/ets/pages. A new project contains Index.ets with a Hello World page.
Do I need a physical device to run the app?
No. You can run it on a device or on the emulator that DevEco Studio supports. A physical device needs automatic signing to be enabled first.