window.openDatabase is not a function

I just encounter an error in Chrome - “Uncaught TypeError: window.openDatabase is not a function.
line 165 column 16”.

The App is working fine last week. Is it the Chrome problem?

I had to do an emergency rewrite on an app for a customer. Seems chrome finally deprecated sqllite. Someone correct me if I’m wrong but my understanding is pwa only have localstorage for offline saving of data, ios even makes that unreliable. I have a few different apps operating in rural New Zealand making offline operation essential but frustrating.

I did see a link to opt in to sqllite till v123

I’m seeing the same thing. Any solutions?

We’re looking at solutions right now. There are three options that we are working on…

  1. Chrome Origin Trial: There is a way to request continued support in Chrome until Chrome 123. We’ve put up experimental instructions for doing this. Give them a try and let us know if it works for you.

  2. Electron: If you distribute your app as an Electron app, SQLite will continue to work. This solution is likely to evolve over time.

  3. SQLite WASM: This is developing to be the most complex solution, but probably the best in the long run. Google themselves says “we expect a significant amount of work will be required”. We’re putting together a way to use this more easily from AppStudio.

Here’s a Wiki page with the solutions so far…

How did you go about resolving this?
For a few years now we have been using an NSBasic webapp we have developed for stock rotation management on our dairy heifer grazing farm in NZ. Like your situation we have limited mobile coverage so we use an offline sqlite database that you sync when you have mobile data access and while out on the farm with no mobile coverage you can continue using the app and you sync again when you are back in mobile coverage. For now I have enabled WebSQL access in chrome under chrome://flags.
My staff would prefer to use their iPhones. IOS support for WebSQL was depricated a while back so I got my staff Android phones but I would like to get back to a solution that is multiplatform.
I am thinking SQLite WASM will be the solution long term.

PowerhouseAg - We’re working on a toolkit to make SQLite WASM easy to use for existing users.

I just dumped sql altogether. Saving to localstorage for what i needed and using the web when I can. I’ve found the actual data needed offline can be relatively small. Limiting and large data work to online use only.

My apps tend to have an “outbox” these days. The app’s code saves to the Outbox when changed and doesn’t even try to save to the server. Events can sit there and upload when online, independent of the apps use.

The multiuser part gets tricky but thats an offline user problem, not an sql problem.

What is the future of IndexedDB for PWAs? Are there any negatives to be aware of? Does it allow storage capacity over localstorage’s limit?

I can’t speak to the future of IndexDB - I’m just as observer as you are. However, it’s a fully supported feature of JavaScript now, and will be for the foreseeable future.

That being said, I prefer the additional power that SQLite gives me in apps, and won’t be switching away from that. We’ll make sure that AppStudio continues to have good support for it.

Can we use any of these this plugins? - npm (

@magieno/sqlite-client - npm (

This is the same approach that we’re taking. We would like to integrate it with AppStudio so npm isn’t needed.

Another hurdle is that the actual calls to SQLite don’t look the same as those currently in AppStudio. If possible, we’d like to make it so existing code will continue to work.

That’s great news, looking forward to it.

Currently I use this, but of course no longer works in the browser (I use sqlitePlugin for Native iOS and Android). I only use Windows for bug testing

If (navigator.userAgent.match(/(ios|iPhone|iPod|iPad|Macintosh)/)) Then
  db = window.sqlitePlugin.openDatabase({name: "my.db", iosDatabaseLocation: "Documents"});
Else If (navigator.userAgent.match(/(Android)/)) Then 
  db = window.sqlitePlugin.openDatabase({name: "my.db", location: "default",  androidDatabaseProvider: "system"});
Else If (navigator.userAgent.match(/(Windows)/)) Then 
  db = SqlOpenDatabase("my.db", "A Database"); //== window.openDatabase is not a function
  alert("Unable to initiate Database!")
End If 

Then I use the same single codebase for the db calls for all platforms.


<code sqlitewasm>
</end code sqlitewasm>

As long as the ide understand this.
Can this be done?

Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)

@tst - Thanks for the suggestion. It’s not quite that simple, unfortunately…