Registry / database / mysql-next

mysql-next

JSON →
library0.1.0jsnpmunverified

A fast, feature-rich MySQL client for Node.js (v0.1.0) leveraging ES6 tagged template literals for parameterized queries. Provides connection pooling, TLS, prepared statement caching, and TypeScript types. Released as an early-stage package targeting modern Node.js >=20.11.0. Compared to mysql2, it offers a simpler API with automatic parameter binding and insert/update helpers, but is newer and less battle-tested.

npm install mysql-next
INSTALL
IMPORT
SIG · MYSQL-NEXT
M
mysql-next
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import mysql from 'mysql-next'
✗ const mysql = require('mysql-next')
ESM-only package; CommonJS require is not supported.
sql
✓ import mysql from 'mysql-next'; const sql = mysql('...')
✗ import { mysql } from 'mysql-next'
The default export is a function; you call it to create a sql tag.
TypeScript types
✓ import type { Sql } from 'mysql-next'
Types are bundled; Sql type represents the tagged template function.

Shows connection using URL, parameterized select query, and insert helper with automatic object-to-column mapping.

import mysql from 'mysql-next' import 'dotenv/config' const sql = mysql(process.env.MYSQL_URL ?? 'mysql://root:password@localhost:3306/app', { max: 10, idleTimeout: 30_000, acquireTimeout: 30_000, prepare: true, maxStatements: 100 }) const users = await sql` select id, name, age from users where age > ${60} ` console.log(users) const result = await sql` insert into users ${sql({ name: 'Murray', age: 68 })} ` console.log('Inserted ID:', result.lastInsertId) await sql.end()
Debug
Known issues
breakingNode.js >=20.11.0 required
fix
Upgrade Node.js to version 20.11.0 or later.
affects: >=0.1.0
gotchaDo not quote interpolated values in queries – they are automatically bound as parameters.
fix
Use ${value} without quotes; the driver handles escaping.
affects: >=0.1.0
gotchaThe 'prepare' option defaults to true; performance may degrade if many distinct queries are used without proper statement caching.
fix
Set 'prepare: false' or adjust 'maxStatements' for workloads with many ad-hoc queries.
affects: >=0.1.0
Errors
Common errors & fixes
Error: The 'mysql-next' package is ESM-only. Use `import` instead of `require`.
Attempting to load the package with CommonJS require().
fix
Change to import syntax: `import mysql from 'mysql-next'`
TypeError: Class extends value undefined is not a constructor or null
The installed mysql-next version does not match Node.js >=20.11.0 requirement.
fix
Ensure Node.js version is 20.11.0 or higher.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
mysql-next — npm install mysql-next · libregistry