{"id":44923,"library":"fastify-sqlite-typed","title":"fastify-sqlite-typed","description":"Fastify plugin for SQLite integration, providing typed database access using node-sqlite3 and node-sqlite. v5.0.2 supports Fastify v5; Fastify v4 compatible branch available. Features configurable driver settings (verbose, cached, tracing), in-memory/disk databases, and multiple mode flags. Ships TypeScript types. Released under MIT license.","status":"active","version":"5.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/yoav0gal/fastify-sqlite-typed","tags":["javascript","typescript"],"install":[{"cmd":"npm install fastify-sqlite-typed","lang":"bash","label":"npm"},{"cmd":"yarn add fastify-sqlite-typed","lang":"bash","label":"yarn"},{"cmd":"pnpm add fastify-sqlite-typed","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - plugin requires Fastify instance","package":"fastify","optional":false}],"imports":[{"note":"Named export; plugin is wrapped with fastify-plugin to avoid encapsulation issues.","wrong":"const { fpSqlitePlugin } = require('fastify-sqlite-typed')","symbol":"fpSqlitePlugin","correct":"import { fpSqlitePlugin } from 'fastify-sqlite-typed'"},{"note":"Named export, not default. Use without fastify-plugin wrapper if you want to manage encapsulation yourself.","wrong":"import sqlitePlugin from 'fastify-sqlite-typed'","symbol":"sqlitePlugin","correct":"import { sqlitePlugin } from 'fastify-sqlite-typed'"},{"note":"Exported enum for database mode flags (READWRITE, CREATE, etc.). TypeScript only.","wrong":"","symbol":"Dbmode","correct":"import { Dbmode } from 'fastify-sqlite-typed'"}],"quickstart":{"code":"import fastify from 'fastify';\nimport { fpSqlitePlugin } from 'fastify-sqlite-typed';\n\nconst app = fastify();\n\napp.register(fpSqlitePlugin, {\n  dbFilename: ':memory:',\n  mode: 0x00000002 | 0x00000004, // READWRITE | CREATE\n});\n\napp.get('/users', async (request, reply) => {\n  const users = await app.db.all('SELECT * FROM users');\n  reply.send(users);\n});\n\napp.listen({ port: 3000 }, (err, address) => {\n  if (err) throw err;\n  console.log(`Server listening on ${address}`);\n});","lang":"typescript","description":"Shows basic registration with in-memory SQLite database and a route querying all users."},"warnings":[{"fix":"For Fastify v4, install the package from the Fastify-V4.x.x branch (e.g., `npm install yoav0gal/fastify-sqlite-typed#Fastify-V4.x.x`).","message":"Requires Fastify v5, not compatible with v4. Use v4 branch for Fastify v4.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Import `fpSqlitePlugin` instead of `sqlitePlugin` unless you understand Fastify encapsulation.","message":"Must use `fpSqlitePlugin` (wrapped with fastify-plugin) to avoid encapsulation issues. Using `sqlitePlugin` may cause `app.db` to be undefined outside the plugin scope.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set `dbFilename` to ':memory:' or a non-empty path.","message":"The plugin does not create a database if `dbFilename` is empty string; use ':memory:' for in-memory or a valid file path.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use numeric values for now; check changelog on upgrade.","message":"Dbmode enum values are numeric; future versions may use string flags.","severity":"deprecated","affected_versions":"<=5.0.2"}],"env_vars":null,"search_vec":"'/disk':41 'access':13 'avail':30 'branch':29 'cach':36 'compat':28 'configur':32 'databas':12,42 'driver':33 'fastifi':2,5,24,26 'fastify-sqlite-typ':1 'featur':31 'flag':46 'in-memori':38 'integr':9 'javascript':54 'licens':53 'memori':40 'mit':52 'mode':45 'multipl':44 'node':16,20 'node-sqlit':19 'node-sqlite3':15 'plugin':6 'provid':10 'releas':50 'set':34 'ship':47 'sqlite':3,8,21 'sqlite3':17 'support':23 'trace':37 'type':4,11,49 'typescript':48,55 'use':14 'v4':27 'v5':25 'v5.0.2':22 'verbos':35","created_at":"2026-06-07T12:52:30.163896+00:00","updated_at":"2026-06-07T12:52:30.163896+00:00","problems":[{"fix":"Run `npm install fastify-sqlite-typed` and use `import { fpSqlitePlugin } from 'fastify-sqlite-typed'`.","cause":"Module not installed or import path incorrect.","error":"Cannot find module 'fastify-sqlite-typed'"},{"fix":"Use `fpSqlitePlugin` import and ensure plugin registration occurs before route definitions.","cause":"Used `sqlitePlugin` without fastify-plugin wrapper, or registered outside route scope.","error":"app.db is undefined"},{"fix":"Ensure `app.register(fpSqlitePlugin, ...)` is called and routes are async with proper await on db methods.","cause":"Database not opened properly; likely missing `await` or incorrect plugin registration.","error":"TypeError: db.all is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/yoav0gal/fastify-sqlite-typed","github":"https://github.com/yoav0gal/fastify-sqlite-typed","docs":null,"changelog":null,"pypi":null,"npm":"fastify-sqlite-typed","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}