A modern, full-stack template for building decentralized applications on the Internet Computer using Rust backend canisters and Next.js 16 frontend, powered by IC Reactor v3 for type-safe canister interactions.
Click the "Use this template" button at the top of this repository, then:
git clone https://github.com/YOUR_USERNAME/YOUR_NEW_REPO.git
cd YOUR_NEW_REPO
npm install# Clone the template
npx degit b3hr4d/ic-rust-nextjs my-icp-app
# Navigate to project
cd my-icp-app
# Install dependencies
npm install# Clone with full history
git clone https://github.com/b3hr4d/ic-rust-nextjs.git my-icp-app
cd my-icp-app
# Remove original git history and start fresh
rm -rf .git
git init
# Install dependencies
npm installπ‘ Tip: After cloning, update the project name in
package.json,dfx.json, andCargo.tomlto match your project.
- π Next.js 16 with React 19 & Turbopack
- π¦ Rust Backend with IC CDK
- β‘ IC Reactor v3 - Type-safe canister interactions with TanStack Query caching
- π Internet Identity - Built-in authentication support
- π¨ Modern Dark UI - Beautiful ICP-themed design
βββ backend/ # Rust canister code
β βββ hello/ # Hello world canister
β βββ Cargo.toml # Rust dependencies
β βββ src/
β βββ lib.rs # Canister logic
βββ src/
β βββ components/ # React components (Login, Greeting)
β βββ declarations/ # Auto-generated canister interface
β βββ lib/
β β βββ reactor.ts # IC Reactor setup (ClientManager + Reactor)
β β βββ hooks.ts # Typed React hooks for canister calls
β βββ pages/ # Next.js pages
β βββ styles/ # CSS styles
βββ dfx.json # Canister configuration
βββ package.json
Before getting started, make sure you have the following installed:
- Node.js (v18+)
- DFINITY Canister SDK (dfx)
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)" - Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup target add wasm32-unknown-unknown
# Install Node.js dependencies
npm install
# Install Rust tools for canister development
npm run candid:install # Install candid-extractor
npm run ic-wasm:install # Install ic-wasm optimizer# Terminal 1: Start local IC replica
npm run dfx:start
# Terminal 2: Deploy canisters (including Internet Identity)
dfx deploy
# Terminal 3: Start Next.js development server
npm run devOpen http://localhost:3000 to see the app.
This template uses IC Reactor v3's new patterns for type-safe canister interactions:
import { ClientManager, Reactor } from "@ic-reactor/react"
import { QueryClient } from "@tanstack/react-query"
const queryClient = new QueryClient()
const clientManager = new ClientManager({ queryClient, withProcessEnv: true })
export const helloReactor = new Reactor<_SERVICE>({
clientManager,
idlFactory,
canisterId
})import { createActorHooks, createAuthHooks } from "@ic-reactor/react"
// Authentication hooks
export const { useAuth, useAgentState } = createAuthHooks(clientManager)
// Canister hooks
export const { useActorQuery, useActorMutation } =
createActorHooks(helloReactor)import { useActorMutation } from "lib/hooks"
function Greeting() {
const { mutate, data, isPending } = useActorMutation({
functionName: "greet"
})
return (
<button onClick={() => mutate(["World"])}>
{isPending ? "Loading..." : data || "Click to greet"}
</button>
)
}| Script | Description |
|---|---|
npm run dev |
Start Next.js development server |
npm run build |
Build Next.js for production |
npm run dfx:start |
Start local IC replica |
npm run dfx:stop |
Stop local IC replica |
dfx deploy |
Deploy all canisters |
npm run dfx:generate |
Generate TypeScript declarations |
# Deploy to mainnet (requires cycles)
dfx deploy --network=icAfter cloning, update these files with your project name:
package.json- Updatenameanddescriptiondfx.json- Rename canister fromhelloto your namebackend/hello/Cargo.toml- Update package namesrc/declarations/- Runnpm run dfx:generateto regenerate
- Create a new directory in
backend/your_canister/ - Add canister configuration to
dfx.json - Create a new Reactor in
src/lib/reactor.ts - Generate hooks with
createActorHooks()
dfx command not found
# Re-run the install script
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"Rust wasm32 target not found
rustup target add wasm32-unknown-unknownPort 4943 already in use
npm run dfx:stop
npm run dfx:startCandid generation fails
npm run candid:install
npm run dfx:generateContributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE for details.
Built with β€οΈ for the Internet Computer community

