Part 1: Project Setup

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.

Prerequisites

Before you begin, ensure you have:

  • Node.js 18+ installed

  • Basic familiarity with React and Next.js

  • An Anvil API key: (sign up at Anvil)

Project Creation

1. Create a new Next.js project

Start by creating a new Next.js application using the create-next-app tool:

npx create-next-app@latest my-basic-transaction-app
cd my-basic-transaction-app

When prompted for options, select the following:

  • TypeScript: Yes

  • ESLint: Yes

  • Tailwind CSS: Yes

  • src/ directory: Yes

  • App Router: Yes

  • Use TurboPack: (Optional)

  • Custom Import Alias (@/*): No

2. Install Required Dependencies

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

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:

  1. Modify the existing home page at src/app/page.tsx. Next.js has already created this file during setup. Replace its contents with:

  1. Start your development server:

  1. Navigate to http://localhost:3000 in your browser. You should see the welcome message.

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.

Last updated

Was this helpful?