π How to Build a WebSocket Tracker using Coinbase Prime API with Node.js + React

Table of contents
- π Introduction
- π Table of Contents
- π 1. Why Use Coinbase Prime WebSocket Feed?
- ποΈ 2. Project Overview
- π οΈ 3. Backend Setup (Node.js + TypeScript)
- π» 4. Frontend Setup (React + WebSocket)
- π 5. Serve Data from Backend to Frontend
- π 6. Displaying Real-time Data
- β 7. Final Thoughts
- π Letβs Connect!

π Introduction
In the world of crypto trading, real-time updates are crucial β price movements, order books, and trade confirmations must be instant. That's where WebSockets shine.
In this tutorial, weβll build a full-stack Coinbase Prime WebSocket Tracker using Node.js (TypeScript) for the backend and React for the frontend. This project is perfect if you're exploring real-time applications, authenticated WebSocket feeds, and crypto APIs.
π Table of Contents
Why Use Coinbase Prime WebSocket Feed?
Project Overview
Backend Setup (Node.js + TypeScript)
Coinbase Prime Authentication (HMAC SHA256)
Frontend Setup (React + WebSocket Client)
Displaying Real-time Data
Final Thoughts
π 1. Why Use Coinbase Prime WebSocket Feed?
Coinbase Prime offers an authenticated WebSocket API that gives you access to channels like:
heartbeat
β Keepalive signalstatus
β Product and system statuslevel2
β Real-time order bookuser
β Personal order updates (authenticated)matches
β Trade executions
Unlike Coinbase Pro, this feed is intended for institutional-grade apps. So if you're building anything real-time and crypto-focused, this is gold.
ποΈ 2. Project Overview
Weβll build:
A backend server to authenticate and subscribe to WebSocket channels from Coinbase Prime
A React frontend that connects to our backend via WebSocket to show real-time updates
Tech stack:
Backend: Node.js, TypeScript,
ws
,crypto
Frontend: React, WebSocket API
π οΈ 3. Backend Setup (Node.js + TypeScript)
π Install Dependencies
npm init -y
npm install ws dotenv crypto axios
npm install -D typescript ts-node @types/node
π Basic WebSocket Client
// src/websocketClient.ts
import WebSocket from 'ws';
import crypto from 'crypto';
import dotenv from 'dotenv';
dotenv.config();
const ws = new WebSocket('wss://advanced-trade-ws.coinbase.com');
const ACCESS_KEY = process.env.ACCESS_KEY!;
const SECRET_KEY = process.env.SECRET_KEY!;
const PASSPHRASE = process.env.PASSPHRASE!;
const ACCOUNT_ID = process.env.ACCOUNT_ID!;
ws.on('open', () => {
console.log('WebSocket connected.');
const timestamp = Math.floor(Date.now() / 1000).toString();
const message = timestamp + 'GET' + '/users/self/verify';
const signature = crypto
.createHmac('sha256', SECRET_KEY)
.update(message)
.digest('base64');
const subscribeMsg = {
type: 'subscribe',
channel: 'heartbeat',
product_ids: ['BTC-USD'],
api_key: ACCESS_KEY,
timestamp,
signature,
passphrase: PASSPHRASE,
};
ws.send(JSON.stringify(subscribeMsg));
});
ws.on('message', (data) => {
console.log('Message:', data.toString());
});
π Environment Variables (.env
)
ACCESS_KEY=your_key
SECRET_KEY=your_secret
PASSPHRASE=your_passphrase
ACCOUNT_ID=your_account_id
π» 4. Frontend Setup (React + WebSocket)
π Basic Setup
npx create-react-app client
cd client
npm install
π WebSocket Component
import React, { useEffect, useState } from 'react';
export default function WebSocketFeed() {
const [messages, setMessages] = useState([]);
useEffect(() => {
const socket = new WebSocket('ws://localhost:3000');
socket.onmessage = (event) => {
const msg = JSON.parse(event.data);
setMessages((prev) => [...prev.slice(-50), msg]); // Keep latest 50
};
return () => socket.close();
}, []);
return (
<div>
<h2>π Real-Time Coinbase Feed</h2>
<ul>
{messages.map((msg, i) => (
<li key={i}>{JSON.stringify(msg)}</li>
))}
</ul>
</div>
);
}
π 5. Serve Data from Backend to Frontend
You can use ws
or socket.io
to create a WebSocket server in Node and broadcast the data received from Coinbase to the frontend.
π 6. Displaying Real-time Data
Once integrated, youβll see:
Heartbeat signals every second
Real-time trade or order data
Dynamic UI changes as events happen
Add styling with Tailwind or Chakra UI, and youβve got a clean, responsive dashboard!
β 7. Final Thoughts
Building a real-time WebSocket tracker is a great way to:
Understand crypto APIs
Work with HMAC authentication
Handle real-time data pipelines
Enhance your portfolio with practical full-stack skills
If you're serious about becoming a Web3 or FinTech developer, this is a strong project to showcase.
π Letβs Connect!
If you liked this, follow me on Hashnode and connect with me on LinkedIn. You can also check out more projects on my GitHub.
π¬ Want the full source code? Drop a comment and Iβll share it with you!
Subscribe to my newsletter
Read articles from Anuj varshney directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Anuj varshney
Anuj varshney
Hey, I am Anuj Varshney a software developer with over a year of experience at iQuinceSoft Pvt Ltd, specializing in web development using various programming languages and tools. He holds a Bachelor of Computer Application degree from Dr. BR Ambedkar University and is currently pursuing a Master of Computer Application from Chandigarh University via distance learning. Anuj has worked on a variety of projects, including the maintenance and updates of CaritasRevolution.com, iQuinceSoft.com, and OdontologiaVejarno.com. His skills include proficiency in programming languages such as JavaScript, C++, C, HTML, and CSS, as well as front-end development using React.js and Nuxt.js. He is also familiar with Node.js, Express.js, MongoDB, and various other tools such as WordPress REST API, Firebase, Redux, Stripe, and Material UI. Anuj is a quick learner with strong analytical skills, and attention to detail, and is committed to delivering high-quality work within tight deadlines.