Nest - modern, fast, powerful node.js web framework (@serve-static)
Last updated 2 months ago by nestjscore .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @nestjs/serve-static 
SYNC missed versions from official npm registry.

Nest Logo

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

NPM Version Package License NPM Downloads Travis Linux Coverage Discord Backers on Open Collective Sponsors on Open Collective


@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


Nest is MIT licensed.

Current Tags

  • 2.1.4                                ...           latest (2 months ago)
  • 2.0.0-next.2                                ...           next (a year ago)

10 Versions

  • 2.1.4                                ...           2 months ago
  • 2.1.3                                ...           7 months ago
  • 2.1.1                                ...           8 months ago
  • 2.1.0                                ...           10 months ago
  • 2.0.0                                ...           a year ago
  • 2.0.0-next.2                                ...           a year ago
  • 2.0.0-next.1                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago

Copyright 2014 - 2016 © taobao.org |