Portfolio Applicaiton
Forked from Helius
Introduction
In this tutorial, you’ll learn how to build a Solana portfolio viewer using Next.js, Tailwind CSS, and the Helius DAS API. We’ll walk through setting up a new Next.js project, creating reusable components, fetching data from the DAS API, and displaying token information dynamically.
Step 1: Setting Up Your Next.js Project
1.1 Create a New Next.js App with Tailwind
Run the following command to create a new Next.js project with TypeScript and ESLint configurations:
npx create-next-app@latest helius-portfolio --typescript --eslintThis command will set up a Next.js project configured to use Tailwind CSS for styling and the new App router.
1.2 Navigate to Your Project Directory
cd helius-portfolio2.1 Create a Components Folder
Create a components folder inside the app directory to maintain an organized structure:
mkdir app/components2.2 SearchBar Component
Create a SearchBar component to handle user input for wallet addresses:
components/SearchBar.tsx
import { useRouter } from "next/navigation";
import React, { useState } from "react";
export default function SearchBar() {
const router = useRouter();
const [address, setAddress] = useState("");
function handleSubmit(event: React.FormEvent) {
event.preventDefault();
router.push(`/${address}`);
}
return (
<form onSubmit={handleSubmit}>
<input
type="text"
value={address}
onChange={(e) => setAddress(e.target.value)}
className="border-2 border-gray-300 rounded-md w-full text-center px-4 py-2 mb-4 flex-grow text-black"
placeholder="Enter Wallet Address"
/>
<button type="submit" className="bg-blue-500 text-white px-4 py-2 rounded-md">
Search
</button>
</form>
);
}2.3 TokenCard Component
Create a TokenCard component to display token information:
components/TokenCard.tsx
Step 3: Fetching Data from DAS
3.1 Create a lib Folder
Create a lib folder inside the app directory for API calls:
3.2 API Call Function
Create a searchAssets.ts file inside the lib folder to handle the DAS API call:
lib/searchAssets.ts
Step 4: Displaying Token Info
4.1 Integrating Components on the Search Page
Set up the search page where users can enter wallet addresses:
pages/index.tsx
4.2 Setting Up the Token Page
Create a directory for dynamic routing and set up a token page:
pages/[wallet]/page.tsx
Step 5: Styling the Application
Tailwind CSS will be our styling framework, allowing us to quickly apply a consistent, responsive design to our application. You can use Tailwind to further customize the look and feel of your app.
Step 6: Testing and Deployment
6.1 Testing Locally
Run your Next.js app locally to test:
Last updated