A Progressive Node.js Framework for Building Efficient and Scalable Server-side Applications

A Progressive Node.js Framework for Building Efficient and Scalable Server-side Applications

Serve static websites (SPA's) using Nest framework (node.js) .A Progressive Node.js Framework for Building Efficient and Scalable Server-side Applications

A progressive Node.js framework for building efficient and scalable server-side applications.


@nestjs/serve-static package for Nest, useful to serve static content like Single Page Applications (SPA). However, if you are building MVC application or want to serve assets files (images, docs), use the useStaticAssets() method (read more here) instead.


$ npm i --save @nestjs/serve-static


See full example here.


Simply import ServeStaticModule in your Nest application.

import { Module } from '@nestjs/common';
import { join } from 'path';
import { ServeStaticModule } from '@nestjs/serve-static';

  imports: [
      rootPath: join(__dirname, '..', 'client')
export class ApplicationModule {}

API Spec

The forRoot() method takes an options object with a few useful properties.

Property Type Description
rootPath string Static files root directory. Default: "client"
serveRoot string Root path under which static app will be served. Default: ""
renderPath string / RegExp Path to render static app (concatenated with the serveRoot value). Default: * (wildcard - all paths)
exclude string[] Paths to exclude when serving the static app. WARNING! Not supported by fastify. If you use fastify, you can exclude routes using regexp (set the renderPath to a regular expression) instead.
serveStaticOptions Object Serve static options (static files)


Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

Download Details:

Author: nestjs

Demo: https://nestjs.com/

Source Code: https://github.com/nestjs/serve-static

node nodejs javascript nestjs

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Node canvas is a Cairo backed Canvas implementation for NodeJS.

node-canvas is a Cairo-backed Canvas implementation for Node.js.

Taming reactive Node.js: Stream-oriented architecture with NestJS

Taming reactive Node.js: Stream-oriented architecture with NestJS. In this Node.js tutorial, Kamil will show you Nest framework as well as introduce you to the world of event-driven systems, CQRS, and Event Sourcing concepts (and how to really take advantage of them).

What Is Nodejs Used For? | Nodejs Use Cases

A decade has passed since initial release of the node.js, it has gained immense popularity. Read in this article, what is nodejs used for? Nodejs Use Cases.

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.

Hire NodeJs Developer

Looking to build dynamic, extensively featured, and full-fledged web applications? **[Hire NodeJs Developer](https://hourlydeveloper.io/hire-dedicated-node-js-developer/ "Hire NodeJs Developer")** to create a real-time, faster, and scalable...