我们可以在 PWA 应用程序中使用 SQLite 数据库吗 [英] can we use SQLite database in PWA app

查看:33
本文介绍了我们可以在 PWA 应用程序中使用 SQLite 数据库吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建 Progressive-web-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

推荐答案

浏览器没有 SQLite,你可以使用 IndexedDBlocalStorage.

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

我假设您正在使用 JWT 或任何其他基于令牌身份验证的工具/库,因此只需保存该令牌,当窗口加载时,您将检查令牌是否存在且仍然有效,如果是,您可以重定向用户转到所需页面或让他导航,逻辑取决于您,但这是您拥有的两个选项.

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.

希望这会有所帮助.

这篇关于我们可以在 PWA 应用程序中使用 SQLite 数据库吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆