Skip to main content

dfx new

Reference

Use the dfx new command to create a new project for the BIG. This command creates a default project structure with template files that you can modify to suit your dapp. You must specify the name of the project to you want to create.

You can use the --dry-run option to preview the directories and files to be created without adding them to the file system.

If called without any arguments besides the project name, it will interactively prompt you for the values of --type, --frontend, and --extras.

Basic usage

dfx new _project_name_ [flag]

Flags

You can use the following optional flags with the dfx new command:

FlagDescription
--dry-runGenerates a preview of the directories and files to be created for a new project without adding them to the file system.
--extras <EXTRAS>Comma-separated list of additional features to add to the project template. bitcoin and internet-identity will insert the appropriate boilerplate into dfx.json, and frontend-tests adds a vitest skeleton to the frontend project.
--frontend <FRONTEND>Installs the template frontend code for the default project canister. The default value for the flag is vanilla if node.js is currently installed on your local computer. If node.js is not currently installed, you can set this flag to attempt to install node.js and the template file when creating the project or you can set the flag to none to skip the installation of template frontend code entirely. Possible values: svelte, react, vue, vanilla, plain-assets, none.
--no-frontendSkips installing the frontend template code. This is the default behavior if node.js is currently not installed on your computer. Equivalent to --frontend none.
--type <TYPE>Selects the template backend code for the default project canister. The default value for the flag is motoko. Possible values: motoko, rust, azle, kybra.

Arguments

You can specify the following argument for the dfx new command.

ArgumentDescription
project_nameSpecifies the name of the project to create. This argument is required.
--typeChoose the canister type in the starter project, motoko and rust are available. The default is motoko.

Examples

You can use dfx new to create a new project named my_social_network by running the following command:

dfx new my_social_network

The command creates a new project, including a default project directory structure under the new project name and a Git repository for your project.

If you want to preview the directories and files to be created without adding them to the file system, you can run the following command:

dfx new my_social_network --dry-run