{"id":15887821,"url":"https://github.com/dabigblob/libsql-stateless-easy","last_synced_at":"2025-08-01T10:37:22.869Z","repository":{"id":206516057,"uuid":"716796161","full_name":"DaBigBlob/libsql-stateless-easy","owner":"DaBigBlob","description":"Thin libSQL stateless HTTP driver for TypeScript and JavaScript for the edge but easy 🚀","archived":false,"fork":false,"pushed_at":"2024-09-14T23:09:52.000Z","size":256,"stargazers_count":69,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-14T11:09:49.661Z","etag":null,"topics":["bun","cloudflare","cloudflare-pages","cloudflare-workers","database","http","https","lambda-functions","libsql","netlify","node-js","nodejs","serverless","serverless-functions","sqlite","vercel","webapi"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/libsql-stateless-easy","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DaBigBlob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-09T22:25:42.000Z","updated_at":"2025-02-21T16:10:44.000Z","dependencies_parsed_at":"2023-12-02T03:23:17.663Z","dependency_job_id":"5535fcda-60ab-4048-ac22-05c89b5581ae","html_url":"https://github.com/DaBigBlob/libsql-stateless-easy","commit_stats":{"total_commits":408,"total_committers":3,"mean_commits":136.0,"dds":0.007352941176470562,"last_synced_commit":"d46e9c48e4e26a6445f7b4e241b1fa1102725af2"},"previous_names":["dabigblob/libsql-stateless-helper","dabigblob/libsql-stateless-easy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-stateless-easy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-stateless-easy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-stateless-easy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-stateless-easy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaBigBlob","download_url":"https://codeload.github.com/DaBigBlob/libsql-stateless-easy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243565415,"owners_count":20311704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","cloudflare","cloudflare-pages","cloudflare-workers","database","http","https","lambda-functions","libsql","netlify","node-js","nodejs","serverless","serverless-functions","sqlite","vercel","webapi"],"created_at":"2024-10-06T06:05:02.602Z","updated_at":"2025-03-14T11:09:54.289Z","avatar_url":"https://github.com/DaBigBlob.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libsql-stateless-easy\n\n\u003e Thin libSQL stateless HTTP driver for TypeScript and JavaScript for the edge but easy 🚀\n- ✅ **Supported runtime environments:** Web API (browser, serverless), Bun, Node.js (\u003e=18)\n- ✅ **Is extremely light:** 8.3kB (unpacked)* / 3.5kB (gzipped)\n- ✅ **Is built for:** Quick stateless query execution. (Mainly for serverless and edge functions.)\n- ✅ Supports everything in `@libsql/client/web` **except `interactive transactions`.\n- ✅ **Is Atomic and stateless**, every function performs complete execution in exactly 1 roundtrip.\n- ✅ **`libsql-stateless-easy` is simply a drop-in replacement** and exactly same API as `@libsql/client/web`.\n\n\\* The actual js that is included with your project. (Excluding the type definitions and 2 copies of the main js for esm and cjs. (because you're gonna use one of them))  \n\\*\\*Interactive transactions are not supported because this lib is stateless but [`transactions`](https://github.com/DaBigBlob/libsql-stateless/wiki/transactions) are supported.\n\u003cbr\u003e\n\n# Installation\n```sh\n$ npm i libsql-stateless-easy #pnpm, yarn, etc.\n# or\n$ bun add libsql-stateless-easy\n```\n\n# Client Usage\n`libsql-stateless-easy`'s `client` has the exact same API as [`@libsql/client/web`](https://docs.turso.tech/sdk/ts/reference)'s `client`.\n```ts\n    import { createClient } from \"libsql-stateless-easy\";\n    //or\n    const { createClient } = require(\"libsql-stateless-easy\");\n\n    const client = createClient({\n        url: \"https://da-fish-mandible.turso.io\",\n        authToken: \"fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg\"\n    });\n    \n    const res = await client.batch([\n        {\n            sql: \"select * from contacts where contact_id = ?;\",\n            args: [3]\n        },\n        \"select first_name, last_name, email from contacts where contact_id = 2\",\n        {\n            sql: \"insert into contacts (contact_id,first_name,last_name,email,phone) values (?,?,?,?,?);\",\n            args: [6,\"glomm\",\"feru\",\"moca@doro.co\",\"001\"]\n        },\n        {\n            sql: \"delete from contacts where contact_id = :kkl\",\n            args: {kkl: 6}\n        }\n    ]);\n    console.log(res);\n\n    const res2 = await client.execute({\n        sql: \"select first_name, last_name, email, contact_id from contacts where contact_id = ?;\",\n        args: [1]\n    });\n    console.log(res2);\n\n    const res3 = await client.execute(\"select first_name, last_name, email, contact_id from contacts where contact_id = 1;\");\n    console.log(res3);\n```\n\n# Drizzle (and other ORMs)\n**`libsql-stateless-easy`'s `client` works with drizzle (and other ORMs) out-of-the-box.**\nThis library implements the same Interface is the official client and therefore works with all the ORMs that the official client works with.\n```ts\n    import { createClient } from \"libsql-stateless-easy\";\n    import { drizzle } from 'drizzle-orm/libsql';\n\n    const client = createClient({\n        url: \"https://da-fish-mandible.turso.io\",\n        authToken: \"fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg\"\n    });\n\n    const db = drizzle(client);\n\n    const result = await db.select().from(table_name).all();\n    console.log(result);\n```\n\n- **This library has the same `LibsqlError` codes as `@libsql/client`**\n\n## Performance\nThis library checks your configs, environments and server compatibility by default.  \nHowever this is _kinda_ resource intensive if you're creating client instances often.  \nSo, **IF YOU ARE SURE YOUR CONFIGURATION, ENVIRONMENT AND SERVER VERSION ARE CORRECT, PLEASE DISABLE THE CHECKS FOR EVEN BETTER PERFORMANCE.**\n```ts\n    const client = createClient({\n        url: \"https://da-fish-mandible.turso.io\",\n        authToken: \"fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg\",\n        disableCriticalChecks: true\n    });\n```\n\n## Custom Fetch\nPass your own implementation of fetch or fetch-like function if you don't want libsql-stateless-easy to use the global fetch or if your global fetch does not exist.\n```ts\n    import { createClient, libsqlFetchLike } from 'libsql-stateless-easy';\n\n    const client = createClient({\n        url: \"https://da-fish-mandible.turso.io\",\n        authToken: \"fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg\",\n        fetch: async (...args: Parameters\u003clibsqlFetchLike\u003e): ReturnType\u003clibsqlFetchLike\u003e =\u003e {\n            //implement your own fetch here (look at examples/custom_fetch for concrete example)\n            /** NOTE:\n             * args[0] is the url string\n             * args[1] is the request init\n             */\n        }\n    });\n\n    const res = await client.execute(\"select * from contacts;\");\n    console.log(res);\n```\n\n## Modularity\n`libsql-stateless-easy` is extremely modular. `execute`, `batch`, etc. can be used without initiating a `client`.  \n```ts\n    import { libsqlBatchTransaction, libsqlExecute } from \"libsql-stateless-easy\";\n    //or\n    const { libsqlBatchTransaction, libsqlExecute } = require(\"libsql-stateless-easy\");\n\n    const config = {\n        url: \"https://da-fish-mandible.turso.io\",\n        authToken: \"fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg\"\n    };\n    \n    const res = await libsqlBatchTransaction(\n        config,\n        [\n            {\n                sql: \"select * from contacts where contact_id = ?;\",\n                args: [3]\n            },\n            \"select first_name, last_name, email from contacts where contact_id = 2\",\n            {\n                sql: \"insert into contacts (contact_id,first_name,last_name,email,phone) values (?,?,?,?,?);\",\n                args: [6,\"glomm\",\"feru\",\"moca@doro.co\",\"001\"]\n            },\n            {\n                sql: \"delete from contacts where contact_id = :kkl\",\n                args: {kkl: 6}\n            }\n        ]\n    );\n    console.log(res);\n\n    const res2 = await libsqlExecute(\n        config,\n        {\n            sql: \"select first_name, last_name, email, contact_id from contacts where contact_id = ?;\",\n            args: [1]\n        }\n    );\n    console.log(res2);\n\n    const res3 = await libsqlExecute(config, \"select first_name, last_name, email, contact_id from contacts where contact_id = 1;\", []);\n    console.log(res3);\n```\n`libsql-stateless-easy`'s `client` just conveniently packages these individually executable functions to conform to the official sdk interface.\n\n### List of other stuff in this library\nFeel free to explore them (however you don't need to as they've been neatly packaged into the `client`)\n```ts\n    import {\n        libsqlValueBuilder, libsqlArgumentsBuilder, libsqlStatementBuilder, libsqlBatchReqStepsBuilder, libsqlBatchReqStepExecCondBuilder, libsqlTransactionBeginStatement,\n        libsqlValueParser, libsqlStatementResParser, libsqlBatchStreamResParser, libsqlTransactionBatchStreamResParser,\n        libsqlExecute, //has easier API than `libsql-stateless`'s function of the same name\n        libsqlBatch, //has easier API than `libsql-stateless`'s function of the same name\n        libsqlServerCompatCheck, //has easier API than `libsql-stateless`'s function of the same name,\n        libsqlBatchTransaction, libsqlExecuteMultiple\n        createClient //used above\n    } from \"libsql-stateless-easy\";\n```\n\n\n## API Level\n\u003e NOTE: current API level is that of latest stable [libsql-stateless](https://github.com/DaBigBlob/libsql-stateless).   \nRead [this section](https://github.com/DaBigBlob/libsql-stateless/?tab=readme-ov-file#api-level).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabigblob%2Flibsql-stateless-easy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabigblob%2Flibsql-stateless-easy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabigblob%2Flibsql-stateless-easy/lists"}