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

269
Views
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 answers
Answer question

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 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!