{"id":46430,"library":"spl.js","title":"spl.js: SpatiaLite for Node.js and Browser","description":"spl.js bundles SpatiaLite 5.1.1-rc0 with SQLite 3.51.1, GEOS 3.14.1, PROJ 9.7.1, and rttopo 1.1.0 for spatial operations in Node.js (sync API) and browsers (async API). Released under ISC license, it provides a unified API for managing spatial databases, importing GeoPackage and Shapefile formats, and handling GeoJSON/JSON transparently. Key differentiators: includes a minimal proj.db for Web Mercator and UTM, supports custom extensions, and auto-detects JSON/GeoJSON bindings. The WASM binary is ~4.5MB gzipped and ships TypeScript definitions. Release cadence is ongoing with version 1.0.1 as of 2025.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/jvail/spl.js","tags":["javascript","spatialite","sqlite","geos","proj","rttopo","typescript"],"install":[{"cmd":"npm install spl.js","lang":"bash","label":"npm"},{"cmd":"yarn add spl.js","lang":"bash","label":"yarn"},{"cmd":"pnpm add spl.js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is a factory function. ESM is needed for browser usage; in Node.js ESM is recommended, but CJS require works with default import interop.","wrong":"const SPL = require('spl.js')","symbol":"SPL","correct":"import SPL from 'spl.js'"},{"note":"db() is an async method that returns a Database instance. Spl is obtained via SPL() factory.","wrong":"const db = spl.db","symbol":"spl.database","correct":"const db = await spl.db()"},{"note":"exec() returns a promise; in browser (async API) you must await. In Node.js it's synchronous by default but can be awaited.","wrong":"const result = db.exec('SELECT 1').get.first","symbol":"db.exec","correct":"const result = await db.exec('SELECT 1').get.first"}],"quickstart":{"code":"import SPL from 'spl.js';\n\nasync function main() {\n  const spl = await SPL();\n  const db = await spl.db();\n  const version = await db.exec('SELECT spatialite_version()').get.first;\n  console.log('SpatiaLite version:', version);\n  await db.exec('CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)');\n  await db.exec('INSERT INTO test VALUES (?, ?)', [1, 'hello']);\n  const row = await db.exec('SELECT * FROM test').get.objs;\n  console.log(row);\n}\nmain().catch(console.error);","lang":"javascript","description":"Shows how to initialize SPL, create an in-memory database, retrieve SpatiaLite version, and perform basic CRUD operations using prepared statements."},"warnings":[{"fix":"Use Chrome or Safari for examples hosted on GitHub Pages, or serve with correct Content-Encoding headers.","message":"Browser requires WebWorker support; Firefox has a known issue with range requests on GitHub Pages that may cause downloads to fail.","severity":"gotcha","affected_versions":">0"},{"fix":"Check SpatiaLite changelog and test extensively before production use.","message":"SpatiaLite 5.1.1-rc0 is a release candidate; some features may be experimental or incomplete.","severity":"gotcha","affected_versions":"1.0.1"},{"fix":"Disable autoGeoJSON option or handle objects explicitly.","message":"Auto JSON/GeoJSON parsing may cause unexpected type coercion. For example, POINT(0 0) becomes a GeoJSON object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use async/await for cross-platform compatibility.","message":"Node.js API is synchronous but returns promises in browser. Mixing sync/async can cause confusion.","severity":"gotcha","affected_versions":">0"},{"fix":"Use spl.fs.mount('proj', [...]) and call PROJ_SetDatabasePath('/proj/proj.db').","message":"Full PROJ database is not included by default; only minimal EPSG. You may need to mount and set custom proj.db.","severity":"gotcha","affected_versions":"1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':92 '1.1.0':21 '2025':95 '3.14.1':16 '3.51.1':14 '4.5':79 '5.1.1':10 '9.7.1':18 'api':28,32,41 'async':31 'auto':71 'auto-detect':70 'binari':77 'bind':74 'browser':6,30 'bundl':8 'cadenc':87 'custom':67 'databas':45 'definit':85 'detect':72 'differenti':56 'extens':68 'format':50 'geo':15,99 'geojson/json':53 'geopackag':47 'gzip':81 'handl':52 'import':46 'includ':57 'isc':35 'javascript':96 'json/geojson':73 'key':55 'licens':36 'manag':43 'mb':80 'mercat':63 'minim':59 'node.js':4,26 'ongo':89 'oper':24 'proj':17,100 'proj.db':60 'provid':38 'rc0':11 'releas':33,86 'rttopo':20,101 'shapefil':49 'ship':83 'spatial':23,44 'spatialit':2,9,97 'spl.js':1,7 'sqlite':13,98 'support':66 'sync':27 'transpar':54 'typescript':84,102 'unifi':40 'utm':65 'version':91 'wasm':76 'web':62","created_at":"2026-06-07T12:59:53.635131+00:00","updated_at":"2026-06-07T12:59:53.635131+00:00","problems":[{"fix":"Run 'npm install spl.js' and ensure import uses 'spl.js' not 'spl'.","cause":"Missing package installation or wrong import path.","error":"Error: Cannot find module 'spl.js'"},{"fix":"Use 'const spl = await SPL()' before calling spl.db().","cause":"SPL() factory not awaited; spl is a Promise, not the SPL instance.","error":"TypeError: spl.db is not a function"},{"fix":"Ensure the server serves WASM with correct MIME type (application/wasm) and has CORS headers.","cause":"The WASM file download failed due to network or CORS issues.","error":"Error: Failed to decode downloaded array buffer"}],"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/jvail/spl.js#readme","github":"https://github.com/jvail/spl.js","docs":null,"changelog":null,"pypi":null,"npm":"spl.js","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}}