Shopify Hydrogen storefront for client

Shopify Hydrogen Storefront

A Shopify Hydrogen app for a client.

Shopify Hydrogen Storefront screenshot

Documentation

๐Ÿ›๏ธ Modern Shopify Hydrogen Storefront

Shopify Hydrogen Storefront

<div align="center">

Become an advanced, confident, and modern Shopify developer from scratch

Build production-ready, headless commerce experiences with the latest tech stack

Node.js TypeScript React Router Shopify Hydrogen

</div>

๐ŸŒŸ Overview

This is a modern, production-ready Shopify Hydrogen storefront built with cutting-edge technologies. Perfect for developers looking to master headless commerce, this project demonstrates professional-grade patterns and best practices used in real-world e-commerce applications.

๐ŸŽฏ What You'll Learn

  • โœ… Shopify Hydrogen Framework - Build blazing-fast storefronts with server-side rendering
  • โœ… Shopify Storefront API - Query products, collections, and customer data with GraphQL
  • โœ… React Router v7 - Modern routing and data loading patterns
  • โœ… TypeScript - Type-safe development with full IDE support
  • โœ… AI-Powered Features - Integrated AI chat for enhanced customer experience
  • โœ… Vector Search - Pinecone integration for semantic product search
  • โœ… Modern UI Components - Shadcn/ui + Radix UI + Tailwind CSS
  • โœ… Docker Deployment - Containerized development and production workflows

๐Ÿ’ผ Job-Ready Skills

Become job-ready by working with libraries and tools used in professional Shopify projects:

  • Professional component architecture
  • Advanced state management
  • GraphQL code generation
  • Performance optimization
  • SEO best practices
  • Accessibility standards (WCAG)
  • Production deployment workflows

๐Ÿš€ Features

๐Ÿ›’ Core E-Commerce

  • Product Catalog - Browse products with advanced filtering and sorting
  • Collections - Organized product collections with pagination
  • Search - Powerful predictive search with instant results
  • Shopping Cart - Full-featured cart with real-time updates
  • Checkout - Seamless Shopify checkout integration
  • Customer Accounts - Authentication and order management

๐Ÿค– AI & Advanced Features

  • AI Chat Assistant - OpenAI-powered product recommendations and support
  • Vector Search - Semantic search using Pinecone for better product discovery
  • Eye Tracking - Advanced UX analytics
  • Dynamic Breadcrumbs - Smart navigation with auto-generated breadcrumbs
  • Responsive Design - Mobile-first, fully responsive UI

๐ŸŽจ Modern UI/UX

  • shadcn/ui Components - 50+ beautiful, accessible components
  • Dark Mode - System-aware theme switching
  • Animations - Smooth transitions and micro-interactions
  • Loading States - Optimistic UI updates
  • Error Boundaries - Graceful error handling

๐Ÿ› ๏ธ Tech Stack

Frontend Framework

Shopify & E-Commerce

AI & Search

UI Components & Styling

Build Tools & Development


๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 18.0.0 or higher (Download)
  • npm 9.0.0 or higher (comes with Node.js)
  • Shopify Store - A Shopify store with Storefront API access
  • Docker (optional) - For containerized development (Download)

๐Ÿ Getting Started

1๏ธโƒฃ Clone the Repository

git clone <your-repo-url>
cd shopify-hydrogen-storefront

2๏ธโƒฃ Install Dependencies

npm install

3๏ธโƒฃ Configure Environment Variables

Create a .env file in the root directory:

# Shopify Store Configuration
PUBLIC_STORE_DOMAIN=your-store.myshopify.com
PUBLIC_STOREFRONT_API_TOKEN=your_storefront_api_token
PRIVATE_STOREFRONT_API_TOKEN=your_private_token

# Checkout & Session
PUBLIC_CHECKOUT_DOMAIN=your-store.myshopify.com
SESSION_SECRET=your_session_secret

# Site Configuration
PUBLIC_SITE_URL=http://localhost:3000

# AI Configuration (Optional)
OPENAI_API_KEY=your_openai_api_key

# Vector Search (Optional)
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_HOST=your_index_host

๐Ÿ”‘ How to Get API Keys:

Shopify API Tokens:

  1. Go to your Shopify Admin โ†’ Settings โ†’ Apps and sales channels
  2. Click "Develop apps" โ†’ "Create an app"
  3. Configure Storefront API permissions
  4. Generate Storefront API access token

OpenAI API Key:

  1. Visit OpenAI Platform
  2. Create an account and navigate to API keys
  3. Generate a new API key

Pinecone API Key:

  1. Visit Pinecone
  2. Sign up for a free account
  3. Create a new index and get your API key

4๏ธโƒฃ Generate GraphQL Types

npm run codegen

This generates TypeScript types from your Shopify GraphQL schema.


๐Ÿ’ป Local Development

Standard Development (Without Docker)

# Start the development server
npm run dev

Your app will be available at:

Docker Development

Prerequisites

  • Docker installed on your machine
  • Docker Compose (usually included with Docker Desktop)

Start with Docker Compose (Recommended)

# Build and start the container
docker-compose -f docker-compose.dev.yml up --build

# Or run in detached mode (background)
docker-compose -f docker-compose.dev.yml up -d --build

Stop Docker Container

# Stop the container
docker-compose -f docker-compose.dev.yml down

# Stop and remove volumes
docker-compose -f docker-compose.dev.yml down -v

Docker Commands Reference

# View logs
docker-compose -f docker-compose.dev.yml logs -f

# Restart container
docker-compose -f docker-compose.dev.yml restart

# Rebuild without cache
docker-compose -f docker-compose.dev.yml build --no-cache

# Execute commands in container
docker-compose -f docker-compose.dev.yml exec hydrogen-dev sh

Alternative: Plain Docker Commands

# Build the image
docker build -f Dockerfile.dev -t hydrogen-storefront-dev .

# Run the container
docker run -p 3000:3000 \
  -v $(pwd):/app \
  -v /app/node_modules \
  --name hydrogen-dev \
  hydrogen-storefront-dev

# Stop container
docker stop hydrogen-dev

# Remove container
docker rm hydrogen-dev

๐Ÿ—๏ธ Building for Production

# Create production build
npm run build

# Preview production build locally
npm run preview

The build output will be in the dist/ directory.


๐Ÿ“ Project Structure

shopify-hydrogen-storefront/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ actions/              # Server-side data mutations
โ”‚   โ”œโ”€โ”€ components/           # React components
โ”‚   โ”‚   โ”œโ”€โ”€ ui/              # shadcn/ui components
โ”‚   โ”‚   โ”œโ”€โ”€ ai/              # AI chat components
โ”‚   โ”‚   โ”œโ”€โ”€ home/            # Home page components
โ”‚   โ”‚   โ”œโ”€โ”€ pageLayout/      # Layout components
โ”‚   โ”‚   โ””โ”€โ”€ search/          # Search components
โ”‚   โ”œโ”€โ”€ graphql/             # GraphQL queries & mutations
โ”‚   โ”œโ”€โ”€ hooks/               # Custom React hooks
โ”‚   โ”œโ”€โ”€ lib/                 # Utilities and helpers
โ”‚   โ”œโ”€โ”€ routes/              # Route handlers (React Router)
โ”‚   โ”œโ”€โ”€ styles/              # Global styles
โ”‚   โ”œโ”€โ”€ entry.client.tsx     # Client entry point
โ”‚   โ”œโ”€โ”€ entry.server.tsx     # Server entry point
โ”‚   โ””โ”€โ”€ root.tsx             # Root component
โ”œโ”€โ”€ public/                   # Static assets
โ”œโ”€โ”€ server/                   # Server configuration
โ”œโ”€โ”€ guides/                   # Documentation guides
โ”œโ”€โ”€ docker-compose.dev.yml   # Docker Compose config
โ”œโ”€โ”€ Dockerfile.dev           # Docker development config
โ”œโ”€โ”€ vite.config.ts           # Vite configuration
โ”œโ”€โ”€ react-router.config.ts   # React Router config
โ””โ”€โ”€ package.json             # Dependencies & scripts

๐Ÿ”Œ API Integration

Storefront API (GraphQL)

Query Shopify data using the Storefront API:

// Example: Fetch products
import {useLoaderData} from 'react-router';

export async function loader({context}) {
  const {storefront} = context;

  const {products} = await storefront.query(PRODUCTS_QUERY, {
    variables: {
      first: 10,
    },
  });

  return {products};
}

export default function Products() {
  const {products} = useLoaderData<typeof loader>();
  // Render products...
}

AI Chat API

Interact with the AI assistant:

// POST /api/chat
const response = await fetch('/api/chat', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    messages: [{role: 'user', content: 'Show me running shoes'}],
  }),
});

Vector Search

Semantic product search with Pinecone:

// Integrated in search components
// Uses embeddings for better product discovery

๐ŸŽจ Customization

Adding New Components

# Add shadcn/ui component
npx shadcn-ui@latest add button

# Component will be added to app/components/ui/

Styling

This project uses Tailwind CSS 4.1. Global styles are in app/styles/globals.css.

// Example component with Tailwind
export function ProductCard({product}) {
  return (
    <div className="rounded-lg border bg-card p-4 shadow-sm">
      <h3 className="text-lg font-semibold">{product.title}</h3>
      <p className="text-muted-foreground">{product.description}</p>
    </div>
  );
}

Theme Configuration

Edit app/styles/globals.css to customize your color palette:

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    /* ... */
  }
}

๐Ÿงช Code Quality

Type Checking

npm run typecheck

Linting

npm run lint

Code Generation

npm run codegen

Generates TypeScript types from:

  • Shopify Storefront API schema
  • Shopify Customer Account API schema
  • React Router routes

๐Ÿš€ Deployment

Deploy to Shopify Oxygen

# Build and deploy
npm run build
npx shopify hydrogen deploy

Deploy to Other Platforms

This app can be deployed to any Node.js hosting platform:

  • Vercel - Connect your Git repo
  • Netlify - Use the build command: npm run build
  • Railway - Deploy with Dockerfile
  • Fly.io - Use the provided Dockerfile
  • AWS / GCP / Azure - Deploy as containerized app

๐Ÿ“š Learning Resources

Official Documentation

Guides

Check the guides/ directory for detailed tutorials:

  • guides/search/ - Implementing predictive search
  • guides/predictiveSearch/ - Advanced search patterns

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Use ESLint and Prettier configurations
  • Write meaningful commit messages
  • Add JSDoc comments for complex functions
  • Test your changes thoroughly

๐Ÿ› Troubleshooting

Common Issues

Port 3000 already in use:

# Kill the process using port 3000
lsof -ti:3000 | xargs kill -9

GraphQL types not generating:

# Ensure your .env file has correct API tokens
npm run codegen -- --force

Docker container exits immediately:

# Check logs
docker-compose -f docker-compose.dev.yml logs

# Rebuild without cache
docker-compose -f docker-compose.dev.yml build --no-cache

Module not found errors:

# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ’ก Make Money with Shopify Apps

This project demonstrates the skills needed to build and sell Shopify Hydrogen apps. With this foundation, you can:

  • ๐ŸŽฏ Build custom storefronts for clients
  • ๐Ÿช Create and sell Shopify apps on the App Store
  • ๐Ÿ’ผ Offer Shopify development services
  • ๐Ÿš€ Launch your own e-commerce brand
  • ๐Ÿ“š Create educational content and courses

Ready to become a professional Shopify developer? Start building today! ๐Ÿš€


<div align="center">

Built with โค๏ธ using Shopify Hydrogen

Report Bug ยท Request Feature

</div>