Have ideas to improve npm?Join in the discussion! »

    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    Simple Files Server

    An easy to use, static files server made in Node.js

    Use case

    Its focused on serve static files like front-end files.

    How to use


      <command> <source> <options>
    • command: the command to execute the server, you can use one of those, simple-files-server, sf-server, sfs.
    • source: optional file or folder to serve, the server will serve the file or search for the index.html file if source is a folder. Default: ./
    • options:
      • port: optional the port to start the server. Default: 3500.
      • spa: optional a boolean value, if its is true the server will serve the index.html file if the request path wasn't for a file and no index.html file was found in the path, for example /about. Default: false.


    const filesServer = require('simple-files-server')
    const port = process.env.PORT || 3500
    const server = filesServer({
      //Server Options
    server.listen(port, /* Custom Log */)

    Server Options

    • source: equal to source cli option.
    • spa: equal to spa cli option.
    • mimeTypes: optional mime types of files to serve, can be override with an object or use a function that will receive the default mime types as first parameter and the return of this function will be the new mime types options.

    Default MIME types:

      txt: 'text/plain',
      html: 'text/html',
      css: 'text/css',
      js: 'text/javascript',
      xml: 'application/xml',
      ts: 'application/typescript',
      json: 'application/json',
      pdf: 'application/pdf',
      jpg: 'image/jpeg',
      png: 'image/png',
      gif: 'image/gif',
      svg: 'image/svg+xml',
      ico: 'image/x-icon',
      otf: 'font/otf',
      ttf: 'font/ttf'

    Custom Log

    By default, this function is optional and will show the default logs when start the server. But you can provide a function, which receive the port as first parameter, and write your own logs.


    npm i simple-files-server

    DownloadsWeekly Downloads






    Unpacked Size

    8.46 kB

    Total Files


    Last publish


    • avatar