This is Part 1 of our guide to building a Cardano transaction application with Next.js and Weld. In this section, you'll set up the project structure and dependencies.
Introduction
In this first part, we'll create a Next.js application and configure it to work with Anvil API. By the end of this section, you'll have a working development environment ready for wallet integration.
Next, install Weld and other required dependencies:
This single package includes everything needed for the client-side wallet integration. Other dependencies (e.g., Next.js, Tailwind CSS) should already be installed as part of the project creation. See the Weld Documentation for more information.
The @ada-anvil/weld package includes all the necessary functionality for wallet integration. The React-specific hooks are exported from the package via the /react subpath: @ada-anvil/weld/react.
3. Environment Configuration
Create a .env.example file to document the required environment variables for other developers:
This file can be safely committed to your repository.
Next, create a .env.local file at the root of your project with your actual values
Never commit your .env.local file to version control. Add it to your .gitignore file to keep your API key secure.
4. Project Structure
The project will be built incrementally across all three parts of this guide. Here's a preview of the complete project structure you'll create:
In Part 1 (this guide), we'll focus on setting up the basic Next.js application structure, configuring environment variables, and adding styles. The implementation of specific components and API routes will come in Parts 2 and 3.
5. Basic Styling
Create a consistent look and feel by adding basic styles to your src/app/globals.css file: We are using custom styles for the paper, button, and custom-rounded classes. You can modify these styles to match your desired design. Or you can use Tailwind's built-in utilities to create your own styles. For now, copy the following code into your src/app/globals.css file:
Verify Your Setup
Let's make sure your setup is working correctly:
Modify the existing home page at src/app/page.tsx. Next.js has already created this file during setup. Replace its contents with:
Start your development server:
Navigate to http://localhost:3000 in your browser. You should see the welcome message.
Congratulations! You've completed Part 1 of the guide. You now have a Next.js project ready for Cardano wallet integration.
What's Next?
Now that you have a basic Next.js application set up, you're ready to integrate the Weld wallet connector. In Part 2: Wallet Integration, we'll implement the wallet connection functionality.