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.

The DataTables 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.

For example - no arguments:

var $       = require( 'jquery' );
var dt      = require( 'datatables.net' )();
var buttons = require( 'datatables.net-buttons' )();

And with the window and jQuery arguments supplied:

var $       = require( 'jquery' );
var dt      = require( 'datatables.net' )( window, $ );
var buttons = require( 'datatables.net-buttons' )( window, $ );

The styling libraries will automatically resolve their own core library dependencies. In the above example the packages datatables.net and datatables.net-buttons are automatically resolved.

It is important to note that not all styling packages contain Javascript - some require CSS only in order to be correctly styled. Packages where this is the case are marked below with a Styling via CSS only comment.

NPM package installation

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

DataTables core

npm install datatables.net
npm install datatables.net-dt

Extensions

AutoFill
npm install datatables.net-autofill
npm install datatables.net-autofill-dt
Buttons
npm install datatables.net-buttons
npm install datatables.net-buttons-dt

Note that using require('datatables.net-buttons')(); will include only the code 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:

require( 'datatables.net-buttons/js/buttons.colVis.js' )(); # Column visibility
require( 'datatables.net-buttons/js/buttons.html5.js' )();  # HTML 5 file export
require( 'datatables.net-buttons/js/buttons.flash.js' )();  # Flash file export
require( 'datatables.net-buttons/js/buttons.print.js' )();  # Print view button
ColReorder
npm install datatables.net-colreorder
npm install datatables.net-colreorder-dt // Styling via CSS only
FixedColumns
npm install datatables.net-fixedcolumns
npm install datatables.net-fixedcolumns-dt // Styling via CSS only
FixedHeader
npm install datatables.net-fixedheader
npm install datatables.net-fixedheader-dt // Styling via CSS only
KeyTable
npm install datatables.net-keytable
npm install datatables.net-keytable-dt // Styling via CSS only
RowGroup
npm install datatables.net-rowgroup
npm install datatables.net-rowgroup-dt // Styling via CSS only
Responsive
npm install datatables.net-responsive
npm install datatables.net-responsive-dt
Scroller
npm install datatables.net-scroller
npm install datatables.net-scroller-dt // Styling via CSS only
Select
npm install datatables.net-select
npm install datatables.net-select-dt // Styling via CSS only