Next.js Discord

Discord Forum

Read public folder

Answered
Griffon Bleu de Gascogne posted this in #help-forum
Open in Discord
Griffon Bleu de GascogneOP
Hello, i want to import multiples images from my public folder with the same css class with Next/Images can you tell me how i can read it ? I think fs and path are the solution but IDK how i can do it
Answered by Coffee Coke
you have multiple options, first is to enter your paths in the array and then map it and return image components with an array item in the src prop. You could also use import() or React.lazy() to dynamicly import images if this is what you need
View full answer

2 Replies

@Griffon Bleu de Gascogne Hello, i want to import multiples images from my public folder with the same css class with Next/Images can you tell me how i can read it ? I think fs and path are the solution but IDK how i can do it
you have multiple options, first is to enter your paths in the array and then map it and return image components with an array item in the src prop. You could also use import() or React.lazy() to dynamicly import images if this is what you need
Answer