can we use SQLite database in PWA app
Asked Answered
T

2

9

I am creating Progressive-web-app application ,I want to store user information in local device. So, how can i do this.how can I store user login information,so that he does not have to login again and again

Testa answered 15/2, 2018 at 12:24 Comment(3)
Possible duplicate of Local Storage vs CookiesKimberli
set the cookie expire time for longer period like 1 year or 2 year. So that user will be logged out after a longer period which will feel like they are always logged in. And if you are looking for store data like sqllite, you can use indexeddb. check this out article for more help on how tostore data - ujjwalguptaofficial.blogspot.in/2017/10/angular4-crud-operation-in-indexeddb.htmlOrganicism
A new interesting way to do this thanks to FileSystemAccesAPIs is to load the SQLite DB from the file system. I've discussed pros and cons here: anita-app.com/blog/articles/…Delftware
A
6

There's no SQLite for browsers, the closer you can achieve is using IndexedDB or localStorage.

I'm assuming you're using JWT or any other token authentication based tool/library, so just save that token and when the window load you'll check if the token is present and still valid, if so you can redirect the user to a desired page or let him navigate, the logic is up to you, but these are the two options you have.

Hope this helps.

Anemic answered 15/2, 2018 at 12:47 Comment(1)
Since 2022 there is now an official support (sqlite.wasm), and since 2012 multiple unofficial ones.Unprofessional
U
4

You can use SQLite in modern WASM-capable browsers thanks to the official sqllite.wasm :

There is also a persistent storage option via:

  • local storage
  • session storage
  • OPFS (Origin-Private FileSystem)

You can even use it without WebAssembly since 2012.

Unprofessional answered 6/3, 2023 at 16:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.