Palak Jain
Palak Jain

Reputation: 143

can we use SQLite database in PWA app

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

Upvotes: 9

Views: 14185

Answers (2)

glautrou
glautrou

Reputation: 3198

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.

Upvotes: 5

Gabriel Barreto
Gabriel Barreto

Reputation: 6421

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.

Upvotes: 6

Related Questions