Skip to main content

Default project template

Getting started


The dfx new <project_name> command creates a new project directory, template files, and a new <project_name> Git repository for your project.

When creating new projects with dfx, only alphanumeric characters and underscores should be used. This is to assure that project names are valid within Motoko, JavaScript, and other contexts.

Exploring the default project structure

By default, the project structure will resemble the following:

├── # Default project documentation
├── dfx.json # Project configuration file
├── node_modules # Libraries for frontend development
├── package-lock.json
├── package.json
├── src # Source files directory
│ ├── hello_backend
│ │ └──
│ ├── hello_frontend
│ ├── assets
│ │ ├── logo.png
│ │ ├── main.css
│ │ └── sample-asset.txt
│ └── src
│ ├── index.html
│ └── index.js
└── webpack.config.js

In this directory, the following files and directories are notable:

  • The default README file to be used for documenting your project.
  • dfx.json: The default configuration file used to set configurable options for your project.
  • src/: The source directory that contains all of your dapp's source files.
  • hello_backend: The source directory that contains your dapp's backend code files.
  • hello_frontend: The source directory that contains your dapp's frontend code files.

Why are there two canisters, hello_backend and hello_frontend?

The hello_frontend canister is used to store the dapp's frontend assets, such as HTML, CSS, JavaScript, React, images, videos, and other media to be displayed in the app's user interface.

The hello_backend canister is used to store the dapp's code and core logic.

A canister is capable of storing both the frontend assets and backend code, but using two canisters with a dedicated canister for the frontend means that any language can be used for the backend canister without needing a library for the assets storage API.

Reviewing the default configuration

By default, the dfx.json file will contain automatically generated configuration settings for your new project. This file is used to configure the components of your project:

"canisters": {
"hello_backend": {
"main": "src/hello_backend/",
"type": "motoko"
"hello_frontend": {
"dependencies": [
"frontend": {
"entrypoint": "src/hello_frontend/src/index.html"
"source": [
"type": "assets"
"defaults": {
"build": {
"args": "",
"packtool": ""
"output_env_file": ".env",
"version": 1

Reviewing the default program code

The backend canister's code will be located in the src/hello_backend subdirectory.

actor {
public query func greet(name : Text) : async Text {
return "Hello, " # name # "!";

Next steps

To interact with this code, you first need to deploy the canister. To learn how to deploy to a local developer environment, see the documentation here: