Creating an Odoo Product web page to mix Odoo API with React Js then makes you some of the highly effective e-commerce platforms.
We are going to information you thru this weblog step-by-step that tips on how to create product web page utilizing Odoo API.

Getting Began
We have to arrange a React Js mission to start out and implement Tailwind CSS for an efficient design of the product web page.
- Create a React Venture
- Setup Tailwind CSS
- Setup React Router
- Create Product web page Part
- Mount Product Part
Step 1: Create a React Venture
Open your terminal and kind the command under to create a brand new mission.
npx create-react-app odoo-product-page cd odoo-product-page
Navigate to Venture root listing:
cd odoo-product-page
Step 2: Setup Tailwind CSS
And Now we are able to set up Tailwind CSS and its dependencies by way of npm:
npm set up -D tailwindcss postcss autoprefixer npx tailwindcss init
This can generate a tailwind.config.js
file in your mission root, the place you’ll be able to configure Tailwind CSS
Configure Tailwind CSS
Open the tailwind.config.js file and arrange the content material paths i.e embrace all information to scan for sophistication names.
module.exports = { content material: [ "./src/**/*.{js,jsx,ts,tsx}", // Add paths to all components ], theme: { lengthen: {}, }, plugins: [], }
Within the src listing, open the index.css file and add the next traces to import tailwind’s base, parts, and utilities types:
@tailwind base; @tailwind parts; @tailwind utilities;
After Creating a brand new mission, you’ll be able to see the ultimate folder construction.
. ├── src/ │ ├── App.js │ ├── App.css │ ├── App.check.js | ├── index.js | ├── index.css │ └── brand.svg ├── public/ │ ├── index.html │ ├── brand.svg │ ├── robots.txt │ └── manifest.json ├── package-lock.json ├── bundle.json ├── tailwind.config.js └── README.md
Step 3: Set up the React Router Dom Packages
Principally, React Router is used to outline a number of routes within the utility, so we’ll add React Router to navigate to the product web page.
npm set up react-router-dom
and we are able to run the command to run React app. and Tailwind CSS and routing will now be useful.
npm run begin
Step 4: Create the Product Web page Part
We’ll begin by making a file named ProductPage.js
within the src/parts
folder.
import React, { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; const ProductPage = () => { const [quantity, setQuantity] = useState(1); const [product, setProduct] = useState(); const { sku = "" } = useParams(); // Operate to make the API request const postData = () => { fetch("Your-ODOO-API-ENDPOINT", { methodology: "POST", headers: { "Content material-Sort": "utility/json; charset=utf-8", Authenticate: "Your Authenticate Key", }, physique: JSON.stringify({ filter: { url_key: { eq: sku } }, }), }) .then((response) => { if (!response.okay) { throw new Error("Community response was not okay"); } return response.json(); }) .then((knowledge) => { console.log("Response Knowledge:", knowledge); setProduct(knowledge); }) .catch((error) => { console.error("Response Error:", error); }); }; useEffect(() => { postData(); }, []); const productdetail = product?.merchandise?.objects?.[0]; return (); }; export default ProductPage;![]()
{productdetail?.description}
$299.99
{amount}
The ProductPage element in React shows sections like a picture, product particulars, and a amount selector. It fetches product knowledge from an API and presents ‘Add to Cart’ and ‘Purchase Now’ actions.
Step 5: Mount the Product Compoment
Open App.js
File and change the code to import ProductPage
, Header
, TopBar
, and Footer
, and Router for displaying the product web page.
import { BrowserRouter, Route, Router, Routes } from "react-router-dom"; import "./App.css"; import Footer from "./parts/Footer"; import Header from "./parts/Header"; import ProductPage from "./parts/Product"; import TopBar from "./parts/TopBar"; operate App() { return ( <>> ); } export default App; } />
And Now save or reload your react app.

Conclusion
Congratulations! You’ve efficiently discover ways to create an odoo product web page in React JS.
Begin your Headless Growth with Webkul.
Thanks for studying this weblog.
Hope this weblog helped you to higher perceive tips on how to create an odoo product web page in React Js.
Joyful Coding!!