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

