NPM packages

DataTables and its extensions are available as NPM packages.

As DataTables supports multiple styling frameworks each of the libraries (DataTables and each of its extensions) are split into separate packages for the library's core software and its styling. The result is that you need to install a package for the library's core software plus a styling package in order for it to function and be styled correctly.

DataTables and its accompanying packages will work natively with both ES modules and CommonJS.

ES module loader

To use DataTables and its extensions in a modern ES module environment, install the package you require (from below) and then include them in your package by using import statements for each package:

import DataTable from '';
import '';
import '';

// DataTables initialisation
let table - new DataTable('#myTable', {
    // ... configuration options

Special note for Buttons - only basic buttons are available by default - if you wish to use them all, a couple of extra files need to be loaded in:

import JSZip from 'jszip'; // For Excel export
import PDFMake from 'pdfmake'; // For PDF export

import '';
import '';
import '';


CommonJS loader

As well as ES modules, the packages all also support CommonJS loaders (e.g. older versions of WebPack or Node.js). For example:

var $       = require( 'jquery' );
var dt      = require( '' );
var buttons = require( '' );

Special note for Buttons - using require(''); will include only the base Buttons library, and not the button definitions (such as column visibility, file exporting and print view). These button definition files can be optionally included using:

const JSZip = require('jszip');
const pdfMake = require('pdfmake);

require( '' ); # Column visibility
require( '' );  # HTML 5 file export
require( '' );  # Print view button

Window-less environments

For window-less environments (i.e. not in the web-browser) the DataTables CommonJS packages all export a factory function that can be executed with two optional arguments:

  1. The window object to use (this is require as jQuery in a headless CommonJS environment can require a window with a document attached). If no parameter is given, or it is falsy, window will be used.
  2. The jQuery object that DataTables should be attached to. If no parameter is given, the package will do its own require('jquery') to include jQuery
var $       = require( 'jquery' )( window );
var dt      = require( '' )( window, $ );
var buttons = require( '' )( window, $ );

NPM package installation

Select the styling framework that you wish to use from the buttons below:

The following packages can be installed for DataTables core and its extensions:

# DataTables core
npm install

# AutoFill
npm install

# Buttons
npm install

# ColReorder
npm install

# FixedColumns
npm install

# FixedHeader
npm install

# KeyTable
npm install

# RowGroup
npm install

# RowReorder
npm install

# Responsive
npm install

# Scroller
npm install

# SearchBuilder
npm install

# SearchPanes
npm install

# Select
npm install

# StateRestore
npm install