Skip to main content

Command Palette

Search for a command to run...

Write the code to start serving static files in Express.js.

Updated
1 min read
Write the code to start serving static files in
Express.js.

To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.

app.use(express.static('public'))

Source:

Serving Static Files in Express. expressjs.com/en/starter/static-files.html.

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference