React quick start
One key feature of ICP is its ability to serve web assets directly in a web browser. When an application is deployed to ICP, users from around the world can access it using only the smart contract's URL without requiring the developer set up a domain name or other web configuration.
Deploy a React app in minutes using these steps.
- Linux
- macOS
- Windows
Prerequisites
Download and install Node.js.1. Install the IC SDK.
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
source "$HOME/.local/share/dfx/env"
Confirm the IC SDK has been installed:
dfx --version
Prerequisites
Download and install Node.js. Using HomeBrew is recommended. Apple silicon machines: Download and install Rosetta:softwareupdate --install-rosetta
1. Install the IC SDK.
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
source "$HOME/.local/share/dfx/env"
Confirm the IC SDK has been installed:
dfx --version
Prerequisites
Download and install Windows Subsystem for Linux. Download and install Node.js within your WSL environment.1. Install the IC SDK.
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
source "$HOME/.local/share/dfx/env"
Confirm the IC SDK has been installed:
dfx --version
2. Download the React template.
Create a new empty directory, then download the project template:
mkdir react-project
cd react-project
npx degit rvanasa/vite-react-motoko
This example project uses Motoko, React, and TypeScript template to create a simple counter application.
3. Start dfx
dfx start --background
4. Setup and deploy the project using npm
.
npm run setup
This command runs a script that includes dfx deploy
.
5. Interact with the app.
Open the frontend
URL in a web browser. You'll see the template React frontend interface.
Congratulations, you just created your first internet-native React dapp!