websql-server exposes a sqlite API originally defined at Cordova-SQLitePlugin through Websockets.
websql-client connects to websql-server and implements the WebSQL API.
Install websql-server:
npm install -g websql-server
Start websql-server:
websql-server
Import websql-client (a bower package) and primus in your html (Primus is automatically served by websql-server):
<script src="bower_components/websql-client/dist/websql-client.js"></script>
<script src="http://localhost:8082/primus/primus.js"></script>
Include the initialization code:
var db = window.sqlitePlugin.openDatabase({name: "my.db", location: 1});
A more advanced installation would conditionally load websql-client if a browser environment is detected, otherwise load Cordova-SQLitePlugin.
serve up the whole project as a static site with: http-server (npm package)
navigate to: http://localhost:8080/test/browser/tests/index.html
- Testing and prototyping Cordova Apps in the web browser that use Cordova-SQLitePlugin.
- Running unit tests for code that depends on a websql api (TODO: document how to set this up).
- No limitations of current WebSQL implementations, such as:
- not authorized to use function: random
- maximum database size restrictions
- not able to use a pre-populated sqlite database from a project directory
- not able to use sqlite extensions written it C.
- Sqlite connection, initialization and query caching is retained when you refresh/reload your app. Your app only has to reconnect to the web server through Websockets. This allows for fast livereload incremental app development.