Next.js 15 এর Server-Side Rendering (SSR) ব্যবহার করে 5টি ই-কমার্স সাইট প্রজেক্ট এর কনসেপচুয়াল আর্কিটেকচার এবং মৌলিক কোড স্ট্রাকচার:
1. Electronics E-commerce Store
// pages/index.tsx (SSR Page)
export async function getServerSideProps() {
const products = await fetchElectronicsProducts();
return {
props: {
products
}
}
}
function ElectronicsStorePage({ products }) {
return (
<div>
{products.map(product => (
<ProductCard
key={product.id}
name={product.name}
price={product.price}
image={product.image}
/>
))}
</div>
)
}
2. Fashion Clothing Marketplace
// pages/clothing/[category].tsx
export async function getServerSideProps({ params }) {
const { category } = params;
const products = await fetchCategoryProducts(category);
return {
props: {
category,
products
}
}
}
function ClothingCategoryPage({ category, products }) {
return (
<CategoryLayout category={category}>
<ProductGrid products={products} />
</CategoryLayout>
)
}
3. Grocery Delivery Platform
// pages/grocery/index.tsx
export async function getServerSideProps() {
const categories = await fetchGroceryCategories();
const featuredProducts = await fetchFeaturedGroceryProducts();
return {
props: {
categories,
featuredProducts
}
}
}
function GroceryHomePage({ categories, featuredProducts }) {
return (
<div>
<CategoryCarousel categories={categories} />
<FeaturedProductSection products={featuredProducts} />
</div>
)
}
4. Handmade Crafts Marketplace
// pages/product/[id].tsx
export async function getServerSideProps({ params }) {
const { id } = params;
const product = await fetchProductDetails(id);
const relatedProducts = await fetchRelatedProducts(id);
return {
props: {
product,
relatedProducts
}
}
}
function ProductDetailPage({ product, relatedProducts }) {
return (
<ProductLayout>
<ProductDetails product={product} />
<RelatedProductSection products={relatedProducts} />
</ProductLayout>
)
}
5. Book and Stationery E-commerce
// pages/books/index.tsx
export async function getServerSideProps() {
const genres = await fetchBookGenres();
const topSellingBooks = await fetchTopSellingBooks();
const newReleases = await fetchNewReleaseBooks();
return {
props: {
genres,
topSellingBooks,
newReleases
}
}
}
function BookStorePage({ genres, topSellingBooks, newReleases }) {
return (
<BookStoreLayout>
<GenreNavigation genres={genres} />
<TopSellingSection products={topSellingBooks} />
<NewReleasesSection products={newReleases} />
</BookStoreLayout>
)
}
SSR Benefits Demonstration
SEO Optimization
// Metadata and SEO Enhancement
export async function getServerSideProps() {
const products = await fetchProducts();
return {
props: {
products
},
// Dynamic SEO Metadata
metadata: {
title: 'Latest Products - Our E-commerce Store',
description: 'Explore our wide range of products',
openGraph: {
type: 'website',
locale: 'en_US',
url: 'https://example.com',
title: 'E-commerce Store',
description: 'Best products at best prices',
images: [
{
url: '/og-image.jpg',
width: 1200,
height: 630
}
]
}
}
}
}
Performance Optimization Techniques
- Caching Strategies
export async function getServerSideProps() {
// Server-side caching
return {
props: { ... },
revalidate: 60 // Regenerate page every 60 seconds
}
}
- Selective Data Fetching
export async function getServerSideProps() {
// Fetch only necessary data
const products = await fetchProducts({
select: ['id', 'name', 'price', 'image']
});
}
Key SSR Advantages for E-commerce
- Faster Initial Page Load
- Improved SEO Performance
- Dynamic Content Rendering
- Enhanced User Experience
- Better Performance on Low-end Devices
Recommended Next.js 15 SSR Best Practices
- Use
getServerSideProps for dynamic data
- Implement proper error handling
- Optimize database queries
- Use caching mechanisms
- Minimize payload size
- Implement progressive loading
Performance Monitoring
// Add performance tracking
export async function getServerSideProps() {
const startTime = Date.now();
const products = await fetchProducts();
const loadTime = Date.now() - startTime;
// Log or send performance metrics
logPerformanceMetrics(loadTime);
return { props: { products } }
}
Conclusion
Next.js 15 এর SSR ই-কমার্স সাইটের জন্য একটি শক্তিশালী সমাধান। এটি দ্রুত লোডিং, SEO অপটিমাইজেশন এবং ডাইনামিক কন্টেন্ট রেন্ডারিংয়ের জন্য আদর্শ।