{"id":13523301,"url":"https://github.com/b3hr4d/ic-rust-nextjs","last_synced_at":"2026-01-17T12:24:14.937Z","repository":{"id":153958092,"uuid":"631092931","full_name":"b3hr4d/ic-rust-nextjs","owner":"b3hr4d","description":"A starter template for building decentralized applications on the Internet Computer using Next.js and Rust. Features a Rust backend for canister logic and a Next.js frontend for user interaction. Comes with comprehensive documentation for easy setup and deployment.","archived":false,"fork":false,"pushed_at":"2024-07-14T19:16:25.000Z","size":804,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T00:33:52.932Z","etag":null,"topics":["dfinity","dfinity-nextjs","icp","internet-computer","nextjs","rust","starter-template","template"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b3hr4d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-21T23:09:03.000Z","updated_at":"2024-09-20T07:09:53.000Z","dependencies_parsed_at":"2023-10-16T12:48:42.613Z","dependency_job_id":"a2c054ec-d463-4937-a9a4-f232dd9e5190","html_url":"https://github.com/b3hr4d/ic-rust-nextjs","commit_stats":null,"previous_names":["b3hr4d/ic-rust-nextjs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/b3hr4d/ic-rust-nextjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b3hr4d%2Fic-rust-nextjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b3hr4d%2Fic-rust-nextjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b3hr4d%2Fic-rust-nextjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b3hr4d%2Fic-rust-nextjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b3hr4d","download_url":"https://codeload.github.com/b3hr4d/ic-rust-nextjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b3hr4d%2Fic-rust-nextjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dfinity","dfinity-nextjs","icp","internet-computer","nextjs","rust","starter-template","template"],"created_at":"2024-08-01T06:00:58.674Z","updated_at":"2026-01-17T12:24:14.927Z","avatar_url":"https://github.com/b3hr4d.png","language":"TypeScript","readme":"# Internet Computer - Rust + Next.js Template\n\nA 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.\n\n![Demo - Initial State](public/demo.png)\n\n![Demo - Greeting Response](public/demo-greeting.png)\n\n## 🚀 Quick Start\n\n### Option 1: Use GitHub Template (Recommended)\n\nClick the **\"Use this template\"** button at the top of this repository, then:\n\n```bash\ngit clone https://github.com/YOUR_USERNAME/YOUR_NEW_REPO.git\ncd YOUR_NEW_REPO\nnpm install\n```\n\n### Option 2: Using degit (No Git History)\n\n```bash\n# Clone the template\nnpx degit b3hr4d/ic-rust-nextjs my-icp-app\n\n# Navigate to project\ncd my-icp-app\n\n# Install dependencies\nnpm install\n```\n\n### Option 3: Using Git Clone\n\n```bash\n# Clone with full history\ngit clone https://github.com/b3hr4d/ic-rust-nextjs.git my-icp-app\ncd my-icp-app\n\n# Remove original git history and start fresh\nrm -rf .git\ngit init\n\n# Install dependencies\nnpm install\n```\n\n\u003e 💡 **Tip**: After cloning, update the project name in `package.json`, `dfx.json`, and `Cargo.toml` to match your project.\n\n## ✨ Features\n\n- 🚀 **Next.js 16** with React 19 \u0026 Turbopack\n- 🦀 **Rust Backend** with IC CDK\n- ⚡ **IC Reactor v3** - Type-safe canister interactions with TanStack Query caching\n- 🔐 **Internet Identity** - Built-in authentication support\n- 🎨 **Modern Dark UI** - Beautiful ICP-themed design\n\n## 📁 Project Structure\n\n```\n├── backend/             # Rust canister code\n│   └── hello/           # Hello world canister\n│       ├── Cargo.toml   # Rust dependencies\n│       └── src/\n│           └── lib.rs   # Canister logic\n├── src/\n│   ├── components/      # React components (Login, Greeting)\n│   ├── declarations/    # Auto-generated canister interface\n│   ├── lib/\n│   │   ├── reactor.ts   # IC Reactor setup (ClientManager + Reactor)\n│   │   └── hooks.ts     # Typed React hooks for canister calls\n│   ├── pages/           # Next.js pages\n│   └── styles/          # CSS styles\n├── dfx.json             # Canister configuration\n└── package.json\n```\n\n## 🔧 Prerequisites\n\nBefore getting started, make sure you have the following installed:\n\n1. **[Node.js](https://nodejs.org/)** (v18+)\n2. **[DFINITY Canister SDK (dfx)](https://internetcomputer.org/docs/current/developer-docs/getting-started/install/)**\n   ```bash\n   sh -ci \"$(curl -fsSL https://internetcomputer.org/install.sh)\"\n   ```\n3. **[Rust](https://www.rust-lang.org/tools/install)**\n   ```bash\n   curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n   rustup target add wasm32-unknown-unknown\n   ```\n\n## 🛠️ Installation \u0026 Setup\n\n### 1. Install Dependencies\n\n```bash\n# Install Node.js dependencies\nnpm install\n\n# Install Rust tools for canister development\nnpm run candid:install    # Install candid-extractor\nnpm run ic-wasm:install   # Install ic-wasm optimizer\n```\n\n### 2. Start Local Development\n\n```bash\n# Terminal 1: Start local IC replica\nnpm run dfx:start\n\n# Terminal 2: Deploy canisters (including Internet Identity)\ndfx deploy\n\n# Terminal 3: Start Next.js development server\nnpm run dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) to see the app.\n\n## 🔧 IC Reactor v3 Usage\n\nThis template uses IC Reactor v3's new patterns for type-safe canister interactions:\n\n### Reactor Setup (`src/lib/reactor.ts`)\n\n```typescript\nimport { ClientManager, Reactor } from \"@ic-reactor/react\"\nimport { QueryClient } from \"@tanstack/react-query\"\n\nconst queryClient = new QueryClient()\nconst clientManager = new ClientManager({ queryClient, withProcessEnv: true })\n\nexport const helloReactor = new Reactor\u003c_SERVICE\u003e({\n  clientManager,\n  idlFactory,\n  canisterId\n})\n```\n\n### Generated Hooks (`src/lib/hooks.ts`)\n\n```typescript\nimport { createActorHooks, createAuthHooks } from \"@ic-reactor/react\"\n\n// Authentication hooks\nexport const { useAuth, useAgentState } = createAuthHooks(clientManager)\n\n// Canister hooks\nexport const { useActorQuery, useActorMutation } =\n  createActorHooks(helloReactor)\n```\n\n### Component Usage\n\n```typescript\nimport { useActorMutation } from \"lib/hooks\"\n\nfunction Greeting() {\n  const { mutate, data, isPending } = useActorMutation({\n    functionName: \"greet\"\n  })\n\n  return (\n    \u003cbutton onClick={() =\u003e mutate([\"World\"])}\u003e\n      {isPending ? \"Loading...\" : data || \"Click to greet\"}\n    \u003c/button\u003e\n  )\n}\n```\n\n## 📦 Available Scripts\n\n| Script                 | Description                      |\n| ---------------------- | -------------------------------- |\n| `npm run dev`          | Start Next.js development server |\n| `npm run build`        | Build Next.js for production     |\n| `npm run dfx:start`    | Start local IC replica           |\n| `npm run dfx:stop`     | Stop local IC replica            |\n| `dfx deploy`           | Deploy all canisters             |\n| `npm run dfx:generate` | Generate TypeScript declarations |\n\n## 🌐 Deploy to IC Mainnet\n\n```bash\n# Deploy to mainnet (requires cycles)\ndfx deploy --network=ic\n```\n\n## 🎨 Customizing the Template\n\n### Rename Your Project\n\nAfter cloning, update these files with your project name:\n\n1. **`package.json`** - Update `name` and `description`\n2. **`dfx.json`** - Rename canister from `hello` to your name\n3. **`backend/hello/Cargo.toml`** - Update package name\n4. **`src/declarations/`** - Run `npm run dfx:generate` to regenerate\n\n### Add New Canisters\n\n1. Create a new directory in `backend/your_canister/`\n2. Add canister configuration to `dfx.json`\n3. Create a new Reactor in `src/lib/reactor.ts`\n4. Generate hooks with `createActorHooks()`\n\n## ❓ Troubleshooting\n\n### Common Issues\n\n**dfx command not found**\n\n```bash\n# Re-run the install script\nsh -ci \"$(curl -fsSL https://internetcomputer.org/install.sh)\"\n```\n\n**Rust wasm32 target not found**\n\n```bash\nrustup target add wasm32-unknown-unknown\n```\n\n**Port 4943 already in use**\n\n```bash\nnpm run dfx:stop\nnpm run dfx:start\n```\n\n**Candid generation fails**\n\n```bash\nnpm run candid:install\nnpm run dfx:generate\n```\n\n## 📚 Resources\n\n- [IC Reactor Documentation](https://b3pay.github.io/ic-reactor/)\n- [DFINITY SDK Documentation](https://internetcomputer.org/docs/)\n- [Rust on IC](https://internetcomputer.org/docs/current/developer-docs/backend/rust/)\n- [Next.js](https://nextjs.org/)\n- [Internet Identity](https://identity.ic0.app/)\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eBuilt with ❤️ for the Internet Computer community\u003c/b\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":["Starters"],"sub_categories":["Tutorials and Samples"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb3hr4d%2Fic-rust-nextjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb3hr4d%2Fic-rust-nextjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb3hr4d%2Fic-rust-nextjs/lists"}