Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
NextJS render content from a different page

I've two routes like,

app/products => pages/products/index.js
app/products/1 => pages/products/[page].js

Here both app/products and app/product/1 will render the same content (same product items), is it possible to render app/products/1 content in app/products without writing duplicate code? I could find anything similar in their documentation.

Thanks.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The easiest way is to abstract the content from the page level. No need for tricky code here. pages/products/index.js:

import { ProductPageContent } from 'components/ProductPageContent';
import { getProductData } from 'lib/productData';

export default function ProductsIndexPage() {
  return <ProductPageContent />
}

export async function getStaticProps() {
  const productData = await getProductData();
  return {
     productData,
  }
}

pages/products/[page].js:

import { ProductPageContent } from 'components/ProductPageContent';
import { getProductData } from 'lib/productData';

export default function ProductPagePage() {
 return <ProductPageContent />
}

export async function getStaticProps() {
  const productData = await getProductData();
  return {
     productData,
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

you can create something like template.jsx somewhere in you project and just use this template in your index and [page]

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!