
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
unified-sql-client
Advanced tools
Universal SQL + fetcher client supporting MySQL, MariaDB, PostgreSQL and Neon, including React hook support
unified-sql-client is a universal SQL and data-fetching library for Node.js and React applications. It supports MySQL, MariaDB, PostgreSQL, and Neon serverless, making it suitable for both traditional and serverless environments. It also includes a built-in fetcher React hook for easy data fetching from REST APIs.
npm install unified-sql-client
Make sure your .env file is configured correctly to support dynamic environment-based connections.
DATABASE_URL=postgres://user:password@hostname:port/database
USE_NEON_DRIVER=true
The USE_NEON_DRIVER flag can also be automatically detected if your URL includes .neon.tech.
# Production
DB_HOST=your-production-host
DB_USER=your-production-user
DB_PASSWORD=your-production-password
DB_NAME=your-production-db
# Development (fallback)
DEV_DB_HOST=localhost
DEV_DB_USER=root
DEV_DB_PASSWORD=
DEV_DB_NAME=local_db
The driver is auto-configured depending on NODE_ENV.
useDb)queryEx – safe result + error return:import { useEnvConnection, queryEx } from "unified-sql-client/server";
useEnvConnection("pg"); // Or MySQL
const [result, error] = await queryEx("SELECT * FROM users WHERE id = $1", [1]);
if (error) {
console.error("DB Error:", error);
} else {
console.log("Data:", result);
}
query – direct result:import { query } from "unified-sql-client/server";
const users = await query("SELECT * FROM users");
console.log(users);
fetcher)import { useFetcher, HttpMethod } from "unified-sql-client/fetcher";
const { data, error, isLoading } = useFetcher({
method: HttpMethod.GET,
url: "/api/posts",
});
const { trigger } = useFetcher({
method: HttpMethod.POST,
url: "/api/post",
payload: { title: "Hello", content: "World" },
});
await trigger();
You can also manually set a custom connection:
import { setConnection } from "unified-sql-client/server";
setConnection({
host: "localhost",
user: "admin",
password: "secret",
database: "mydb",
driver: "pg",
});
.env config based on environmentqueryEx<T>()useFetcher hook for API fetchesserver (server-side)query(query: string, args: any[]): Promise<any>queryEx<T>(query: string, args: any[]): Promise<[T | null, DbError | null]>useEnvConnection(driver?: "mysql" | "pg")setConnection(config: DbConnectionConfig)beginTransaction(), commit(), rollback() (MySQL only)fetcher (client-side)useFetcher<T>(options: { method, url, payload? })
{ data, error, isLoading }{ trigger }.env (for Neon)DATABASE_URL=postgres://user:pass@ep-xyz.neon.tech/dbname?sslmode=require
USE_NEON_DRIVER=true
MIT License © 2025 slynxcz
FAQs
Universal SQL + fetcher client supporting MySQL, MariaDB, PostgreSQL and Neon, including React hook support
We found that unified-sql-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.