Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
reading all files in the public folder next.js

I have a folder called Songs in the Public folder. During render time I would like to render them:

const renderSongs = () => {
 [ array of song files ].map(song => {
  ...
 })
}

tho I dont think I can use fs in next.js, so how would i do this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Note: You can import modules in top-level scope for use in getServerSideProps. Imports used in getServerSideProps will not be bundled for the client-side.

This means you can write server-side code directly in getServerSideProps. This includes reading from the filesystem or a database.

Source: https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation

or

https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering

So basically you can use fs, but only in the getStaticProps or getServerSideProps, which will be run at build time, or on the serverside.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda