A modern Next.js e-commerce platform that integrates with 1688.com (Alibaba's wholesale marketplace) to display and browse products directly from Chinese suppliers.
- Real-time Product Search: Search millions of wholesale products from 1688.com
- Product Listings: Beautiful, responsive grid layout for product browsing
- Product Details: Comprehensive product information including images, pricing, MOQ, and supplier details
- API Integration: Secure server-side API integration with Alibaba's Open Platform
- Mock Data Support: Fallback to mock data when API credentials are not configured
- Modern UI: Built with Tailwind CSS for a clean, professional look
- TypeScript: Full type safety throughout the application
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Node.js 18+ installed
- npm or yarn package manager
- 1688.com/Alibaba Open Platform account (for API access)
-
Clone or navigate to the project directory:
cd /Users/ridafakherlden/www/china -
Install dependencies (already done, but if needed):
npm install
-
Configure Environment Variables:
Create a
.env.localfile in the root directory:cp .env.example .env.local
Edit
.env.localand add your Alibaba API credentials:ALIBABA_APP_KEY=your_app_key_here ALIBABA_APP_SECRET=your_app_secret_here ALIBABA_API_URL=https://gw.open.1688.com/openapi NEXT_PUBLIC_SITE_URL=http://localhost:3000
-
Run the development server:
npm run dev
-
Open your browser: Navigate to http://localhost:3000
To use real data from 1688.com, you need to register for API access:
- Go to Alibaba Open Platform
- Create an account or log in with your existing Alibaba account
- Complete the business verification process
- Navigate to the "Application Management" section
- Click "Create Application"
- Fill in your application details:
- Application name
- Description
- Website URL
- Callback URL (for OAuth)
- After application approval, you'll receive:
- App Key (appkey)
- App Secret (secret)
- Copy these credentials to your
.env.localfile
- Apply for the following API permissions:
- Product Search API (
alibaba.product.search) - Product Detail API (
alibaba.product.get) - Image API (for product images)
- Product Search API (
- Wait for approval (usually 1-3 business days)
/Users/ridafakherlden/www/china/
โโโ src/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ products/
โ โ โ โโโ route.ts # Product listing API
โ โ โ โโโ [id]/
โ โ โ โโโ route.ts # Product detail API
โ โ โโโ products/
โ โ โ โโโ page.tsx # Products listing page
โ โ โ โโโ [id]/
โ โ โ โโโ page.tsx # Product detail page
โ โ โโโ layout.tsx # Root layout
โ โ โโโ page.tsx # Home page
โ โ โโโ globals.css # Global styles
โ โโโ components/
โ โ โโโ ProductCard.tsx # Product card component
โ โ โโโ SearchBar.tsx # Search component
โ โ โโโ LoadingSpinner.tsx # Loading state
โ โโโ lib/
โ โ โโโ alibaba-api.ts # API integration utilities
โ โโโ types/
โ โโโ product.ts # TypeScript type definitions
โโโ public/ # Static assets
โโโ .env.local # Environment variables (create this)
โโโ .env.example # Environment template
โโโ package.json
โโโ tsconfig.json
โโโ tailwind.config.ts
โโโ README.md
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- API: Next.js API Routes
- Image Optimization: Next.js Image Component
- State Management: React Hooks
- HTTP Client: Native Fetch API
The application uses HMAC-MD5 signature authentication as required by Alibaba's API:
- Request parameters are sorted alphabetically
- A signature string is generated by concatenating all parameters
- HMAC-MD5 hash is created using the App Secret
- The signature is added to the API request
Fetch a list of products
Query Parameters:
keyword(optional): Search termpage(optional): Page number (default: 1)pageSize(optional): Items per page (default: 20)
Response:
{
"success": true,
"products": [...],
"total": 100,
"page": 1,
"pageSize": 20
}Fetch detailed information for a specific product
Response:
{
"success": true,
"product": {
"id": "123",
"subject": "Product name",
"price": 99.99,
"imageUrl": "https://...",
"description": "...",
...
}
}The application uses Tailwind CSS. To customize the design:
- Edit
tailwind.config.tsfor theme customization - Modify component styles in their respective files
- Update global styles in
src/app/globals.css
If you're testing without API credentials, the application automatically uses mock data. You can customize the mock products in:
src/app/api/products/route.tssrc/app/api/products/[id]/route.ts
- Real-time search through 1688.com products
- Keyword-based filtering
- Pagination support
- Grid layout with responsive design
- Product cards showing:
- Product image
- Title
- Price (with CNY to USD conversion)
- Minimum Order Quantity (MOQ)
- Supplier information
- Sales statistics
- Image gallery with thumbnails
- Comprehensive product information
- Supplier details
- Price range based on quantity
- Product specifications
- Contact supplier functionality
The application displays:
- Prices in Chinese Yuan (CNY) with USD approximation
- MOQ (Minimum Order Quantity) information
- Chinese supplier names and details
Future enhancements could include:
- Multi-language support
- Real-time currency conversion
- Translation of product descriptions
- Push your code to GitHub
- Import the repository in Vercel
- Add environment variables in Vercel dashboard:
ALIBABA_APP_KEYALIBABA_APP_SECRETALIBABA_API_URLNEXT_PUBLIC_SITE_URL
- Deploy!
The application can be deployed to any platform that supports Next.js:
- Netlify
- Railway
- AWS Amplify
- DigitalOcean App Platform
Issue: The application displays mock products even though you've configured API credentials.
Solutions:
- Verify your
.env.localfile has the correct credentials - Check that your API application is approved on Alibaba Open Platform
- Ensure API permissions are granted for product search and detail endpoints
- Check the browser console and server logs for error messages
Issue: API requests return errors or fail.
Solutions:
- Verify your App Key and App Secret are correct
- Check that your IP address is whitelisted (if required by Alibaba)
- Ensure you haven't exceeded API rate limits
- Check the API endpoint URL is correct
Issue: Product images don't display.
Solutions:
- Add 1688.com image domains to
next.config.ts:images: { remotePatterns: [ { protocol: 'https', hostname: '**.1688.com', }, ], }
- Restart the development server after configuration changes
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
For issues related to:
- This application: Create an issue in the repository
- 1688 API: Contact Alibaba Open Platform Support
- Next.js: Check Next.js Documentation
Potential features for future versions:
- Shopping cart functionality
- User authentication
- Order management
- Real-time currency conversion API
- Product comparison tool
- Wishlist/favorites
- Advanced filtering (price range, category, supplier rating)
- Supplier rating and reviews
- Multi-language support
- Translation API for product descriptions
- Payment gateway integration
- Shipping calculator
- Bulk order request form
- Export product data to CSV/Excel
Built with โค๏ธ using Next.js and 1688.com API