This project sets up a headless WordPress WooCommerce site with a Next.js frontend. By utilizing WooCommerce as the CMS (Content Management System) and payment provider, we can create an efficient, dynamic eCommerce platform. The backend (WooCommerce) serves as the product and payment system, while the frontend (Next.js) provides a modern, fast user experience.
WooCommerce's REST API is used to connect the Next.js frontend with the WooCommerce backend. Additionally, PayPal is integrated as the payment provider to securely process transactions.
Client: React, Redux, TailwindCSS , Shadcn, Nextjs
Server: Firebase Auth, Wordpress Woocommerce Rest
Demo Link Hosted On vercel
https://woocommerce-nextjs-rest-api.vercel.app/
Clone the project
git clone https://link-to-projectGo to the project directory
cd my-projectInstall dependencies
npm installStart the server
npm run startThis guide will help you configure the .env file when setting up the ClothVillage project. Follow the steps below to ensure all environment variables are correctly configured.
NEXT_PUBLIC_WORDPRESS_SITE_URL
- This is the backend WordPress site URL.
NEXT_PUBLIC_SITE_URL - This is the frontend URL. Replace it with the domain you use for the frontend (e.g., a Vercel deployment URL).
WC_CONSUMER_KEY=ck_a87bee45cf036ead38159015b3660139962b9c2e
WC_CONSUMER_SECRET=cs_fca482b412b6d14ffe164ab6ff8f4f1d6af17ad9
These keys are generated in WordPress for the REST API. To generate them:
- Log in to your WordPress admin panel.
- Navigate to WooCommerce > Settings > Advanced > REST API.
- Click "Add Key."
- Enter a description, select the user, and set permissions to Read/Write.
- Generate the key and copy the Consumer Key and Consumer Secret into the .env file.
NEXT_PUBLIC_VIEW_CART_URL=https://clothvillage.com/wp-json/cocart/v2/cartNEXT_PUBLIC_ADD_CART_URL=https://clothvillage.com/wp-json/cocart/v2/cart/add-item
These are CoCart endpoints used for cart operations. Note that the URL might change if the backend URL changes, but the endpoints (/cart and /cart/add-item) remain the same.
NEXT_PUBLIC_API_URL=https://clothvillage.com- This is the backend API URL.
NEXT_PUBLIC_PAYPAL_CLIENT_ID=AaMWJxShAuaNSFi30bJSDmVbAwy1LqZgWYyvvFNkkPZEts0uqTh80r2UitF8O32p5odfqFUhzF1Jy0Wq
- To generate a PayPal client ID for payment processing:
- Log in to your PayPal Developer account: https://developer.paypal.com.
- Navigate to Dashboard > My Apps & Credentials.
- Create a new app under REST API apps.
NEXT_PUBLIC_FIREBASE_API_KEY=AIzaSyBw7eEVv205f4cAWFYH_xbmuz5JyPXy8LANEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=clothesvillageauth.firebaseapp.comNEXT_PUBLIC_FIREBASE_PROJECT_ID=clothesvillageauthNEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=clothesvillageauth.firebase.storage.appNEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=448354174238NEXT_PUBLIC_FIREBASE_APP_ID=1:448354174238:web:7bb4de2650c9b3b345b50fNEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-BXJ1P36ZEZ
These are Firebase SDK keys. Ensure they match your Firebase project. If you need to set up a Firebase project:
- Go to Firebase Console.
- Create a new project or select an existing one.
- Navigate to Project Settings > General > Your Apps.
- Add a new app and copy the configuration keys.
If deploying on Vercel, ensure the following:
Update the NEXT_PUBLIC_SITE_URL variable to your Vercel deployment URL.
Add all environment variables in the Vercel dashboard:
Go to Settings > Environment Variables in your Vercel project.
Add the variables one by one.
NEXT_PUBLIC_WORDPRESS_SITE_URL=https://clothvillage.com
NEXT_PUBLIC_SITE_URL=http://localhost:3000
WC_CONSUMER_KEY=ck_a87bee45cf036ead38159015b3660139962b9c2e
WC_CONSUMER_SECRET=cs_fca482b412b6d14ffe164ab6ff8f4f1d6af17ad9
NEXT_PUBLIC_VIEW_CART_URL=https://clothvillage.com/wp-json/cocart/v2/cart
NEXT_PUBLIC_ADD_CART_URL=https://clothvillage.com/wp-json/cocart/v2/cart/add-item
NEXT_PUBLIC_API_URL=https://clothvillage.com
NEXT_PUBLIC_PAYPAL_CLIENT_ID=AaMWJxShAuaNSFi30bJSDmVbAwy1LqZgWYyvvFNkkPZEts0uqTh80r2UitF8O32p5odfqFUhzF1Jy0Wq
NEXT_PUBLIC_FIREBASE_API_KEY=AIzaSyBw7eEVv205f4cAWFYH_xbmuz5JyPXy8LA
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=clothesvillageauth.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=clothesvillageauth
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=clothesvillageauth.firebasestorage.app
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=448354174238
NEXT_PUBLIC_FIREBASE_APP_ID=1:448354174238:web:7bb4de2650c9b3b345b50f
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-BXJ1P36ZEZ
- SEO
- Customer Reviews
- Machine learning for Product Recommendation
- Fuzzy Search
- GraphQL
- Stripe Payment Gateway
- SMS




