Skip to content

Manta-Network/react-dapp-starter

Repository files navigation

React DApp Starter

TypeScript

Overview

react-dapp-starter is a robust and scalable template designed for building decentralized applications (DApps) with modern web technologies. This template is a production-ready foundation currently used in Manta Network, designed to meet the demands of complex and scalable DApp development.

Features

  • TypeScript: Strongly-typed language that builds on JavaScript, giving you better tooling at any scale.
  • React 19: Latest React version with improved performance and new features.
  • React Router 7: A declarative routing library for React that makes it easy to navigate your app.
  • Tailwind CSS 4: Utility-first CSS framework with native Vite integration and CSS-first configuration.
  • Reown AppKit: The toolkit to build onchain app UX with wallet connection support.
  • Wagmi: A set of React Hooks for working with Ethereum.
  • Viem: A toolkit for handling Ethereum-related data and logic.
  • Shadcn UI: A collection of pre-built UI components for a fast and consistent development experience.
  • Zustand: A small, fast, and scalable state management solution for React.
  • TanStack Query: Powerful data fetching, caching, and synchronization for server state management.
  • React Responsive: Media queries in React with custom breakpoint hooks.
  • ESLint & Prettier: Code quality and formatting tools to ensure a clean codebase.

Getting Started

  1. Clone the repository:

    You can use a tool like degit to scaffold your project with this template.

    npx degit Manta-Network/react-dapp-starter#main your-project
    cd your-project
  2. Install dependencies (default: yarn):

    yarn install
  3. Configure WalletConnect Project ID and Metadata:

    • Visit Reown Cloud to create a project and obtain your Project ID.
    • Open the file src/config/common.ts in your project.
    • Locate the WALLET_CONNECT_PROJECT_ID key and replace YOUR_PROJECT_ID with your actual Project ID.
    • Update the WALLET_CONNECT_METADATA section with your project's details, including the name, description, URL, and icons.
  4. Run the development server:

    yarn dev
  5. Build for production:

    yarn build

Responsive Design

This template includes comprehensive responsive design support:

Tailwind CSS Breakpoints

// Use responsive prefixes for different screen sizes
<h1 className="text-2xl md:text-4xl lg:text-5xl">Responsive Title</h1>

// Mobile-specific styles with max-md
<div className="block max-md:hidden">Desktop only</div>
<div className="hidden max-md:block">Mobile only</div>

Custom Breakpoints Hook

import { useResponsive } from '@/hooks/useResponsive';

function MyComponent() {
  const { isMobile, isTablet, isDesktop } = useResponsive();

  return isMobile ? <MobileView /> : <DesktopView />;
}

Fluid Typography (Optional)

For smooth font scaling across viewports (390px - 1440px):

<h1 className="text-[clamp(1rem,0.8143rem+0.7619vw,1.5rem)]">
  Title smoothly scales from 16px to 24px
</h1>

Use the Utopia Fluid Type Calculator to generate custom clamp values.

Project Structure

β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ abis/ # Smart contract ABIs
β”‚ β”œβ”€β”€ api/ # Optional API endpoints definitions
β”‚ β”œβ”€β”€ assets/ # Static assets like images and fonts
β”‚ β”œβ”€β”€ components/ # Reusable UI components
β”‚ β”‚ └── ui/ # Shadcn UI components
β”‚ β”œβ”€β”€ config/ # Application configuration files
β”‚ β”œβ”€β”€ hooks/ # Custom React hooks (useResponsive, etc.)
β”‚ β”œβ”€β”€ lib/ # Utility functions and business logic
β”‚ β”œβ”€β”€ pages/ # Application pages
β”‚ β”œβ”€β”€ store/ # Global state management using Zustand
β”‚ β”œβ”€β”€ types/ # TypeScript types
β”‚ β”œβ”€β”€ AppRouter.tsx # Application routing
β”‚ β”œβ”€β”€ index.css # Global styles & Tailwind CSS configuration
β”‚ β”œβ”€β”€ main.tsx # Main entry point
β”‚ └── vite-env.d.ts # Vite environment variables types
β”œβ”€β”€ public/ # Static public assets
β”œβ”€β”€ .gitignore # Git ignore file
β”œβ”€β”€ .prettierrc # Prettier configuration
β”œβ”€β”€ CHANGELOG.md # Project changelog
β”œβ”€β”€ components.json # Shadcn UI components configuration
β”œβ”€β”€ eslint.config.js # ESLint configuration
β”œβ”€β”€ index.html # Main HTML file
β”œβ”€β”€ package.json # Project metadata and dependencies
β”œβ”€β”€ PROJECT_OVERVIEW.md # Overview of the project
β”œβ”€β”€ README.md # Project README
β”œβ”€β”€ tsconfig.app.json # App TypeScript configuration
β”œβ”€β”€ tsconfig.json # TypeScript configuration
β”œβ”€β”€ tsconfig.node.json # Node.js TypeScript configuration
β”œβ”€β”€ vercel.json # Vercel deployment configuration
β”œβ”€β”€ vite.config.ts # Vite configuration
└── yarn.lock # Yarn lock file

Contributing

Contributions are welcome! Please create an issue or submit a pull request if you find any bugs or have suggestions for improvements.

Acknowledgements

Special thanks to the open-source community and the maintainers of the libraries and tools used in this template.

Releases

No releases published

Packages

 
 
 

Contributors