Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
Dynamic Page Render On Demand Next Js

So, I am working on a simple Next.Js app. It's just a Lyrical Page but I'm running onto some issues. I'm new to Next.Js and this is my first project. So, here is my problem:

I have a dynamic set of pages/folders which looks like this:

  • songs (empty folder)
  • [singer] (child of songs containng just an index.jsx)
  • [title] (child of [singer] containing another index.jsx)

Now in my [title] - index.jsx im rendering a simple page providing lyrics for a specific song. My problem is that I want to count views (every time someone opens this page) for each song sepertly. I have the following code:

export const getStaticProps = async (context) => {
const res = await fetch(`${process.env.PROXY}api/lyrics/post/${encodeURIComponent(context.params.title)}`);

const data = await res.json();

const send = await fetch(`${process.env.PROXY}api/lyrics/views/${data.post._id}`);

return {
  props: {
    data: data.post,
    message: 200
  }
}

}

export const getStaticPaths = async () => {
  const res = await fetch(`${process.env.PROXY}api/lyrics/getAll`);

  const data = await res.json();

  const paths = data.all.map((name) => ({ params: { singer: name.singer.toString(), title: name.title.toString() } }));

  return {
      paths: paths,
      fallback: 'blocking'
  }

}

The problem is I know getStaticProps renders only on build time, however, I want to render every time so that I can count the views with my send variable.

Can someone please help me figure this out? Any help will be appreciated!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda