{"id":21104,"library":"datatables.net","title":"DataTables","description":"DataTables is a powerful JavaScript library for enhancing HTML tables with advanced interaction controls such as pagination, instant search, multi-column sorting, and server-side processing. The current stable version is 2.3.8, released on a regular schedule with minor updates and patches. It requires jQuery as a dependency and provides a rich API for customizing table behavior. DataTables differentiates itself with extensive community support, numerous plugins, and seamless integration with jQuery. A major 3.0 beta is in development, which will introduce breaking changes and new features.","status":"active","version":"2.3.8","language":"javascript","source_language":"en","source_url":"https://github.com/DataTables/Dist-DataTables","tags":["javascript","Datatables","jQuery","table","filter","sort","typescript"],"install":[{"cmd":"npm install datatables.net","lang":"bash","label":"npm"},{"cmd":"yarn add datatables.net","lang":"bash","label":"yarn"},{"cmd":"pnpm add datatables.net","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"DataTables depends on jQuery for DOM manipulation and event handling.","package":"jquery","optional":false}],"imports":[{"note":"Default export provides the DataTable constructor. In CJS environments, use require('datatables.net') with CommonJS, but TypeScript types are designed for ESM default import.","wrong":"const DataTable = require('datatables.net')","symbol":"DataTable","correct":"import DataTable from 'datatables.net'"},{"note":"DataTables requires jQuery globally. Import jQuery separately and ensure it's loaded before DataTables.","wrong":"import DataTable from 'datatables.net'; (missing jQuery import)","symbol":"$","correct":"import $ from 'jquery'; import DataTable from 'datatables.net'"},{"note":"Config is a TypeScript type/interface. Use type-only import to avoid runtime errors.","wrong":"import { Config } from 'datatables.net' (runtime import)","symbol":"type Config","correct":"import type { Config } from 'datatables.net'"}],"quickstart":{"code":"import $ from 'jquery';\nimport DataTable from 'datatables.net';\n\nconst table = new DataTable('#myTable', {\n  paging: true,\n  searching: true,\n  ordering: true,\n  pageLength: 10,\n  serverSide: false,\n  columns: [\n    { data: 'name' },\n    { data: 'position' },\n    { data: 'office' },\n    { data: 'age' },\n    { data: 'salary' }\n  ],\n  data: [\n    { name: 'Tiger Nixon', position: 'System Architect', office: 'Edinburgh', age: 61, salary: '$320,800' },\n    { name: 'Garrett Winters', position: 'Accountant', office: 'Tokyo', age: 63, salary: '$170,750' }\n  ]\n});\n\nconsole.log(table.rows().count());","lang":"typescript","description":"Creates a new DataTable instance from an HTML table element with data, enabling pagination, search, and sorting."},"warnings":[{"fix":"Replace $(...).DataTable() with new DataTable(...) and import DataTable from 'datatables.net'.","message":"DataTables v2 drops the $.fn.dataTable jQuery API. Use the importable DataTable constructor instead.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use new DataTable('#table') from the module instead.","message":"Using $('#table').DataTable() is deprecated in v2 and removed in v3 beta.","severity":"deprecated","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Ensure jQuery is installed and imported: import $ from 'jquery'; then import DataTable.","message":"DataTables requires jQuery to be loaded before importing DataTable. Failing to do so results in a runtime error: 'jQuery is not defined'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use webpack.ProvidePlugin to expose jQuery globally or use imports-loader.","message":"When using DataTables with webpack or similar bundlers, the default import might be undefined if jQuery is not properly provided.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use the module import: import DataTable from 'datatables.net'; new DataTable('#table');","cause":"Trying to call $(...).DataTable() without proper import or before jQuery is loaded.","error":"TypeError: (intermediate value).DataTable is not a function"},{"fix":"Run npm install jquery and import it before DataTables.","cause":"jQuery is not installed as a dependency.","error":"Error: Cannot find module 'jquery'"},{"fix":"Use import type { Config } from 'datatables.net' for TypeScript.","cause":"Trying to use import { Config } from 'datatables.net' at runtime instead of using type-only import.","error":"TS2322: Type 'undefined' is not assignable to type 'Config'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}