Ionic Secure Storage get() at the start of the app

I have a service that gets a token for validate an Auth status at the /src/main.ts:

if (TokenService.getAccessToken() !== undefined) {


import storage from '@/plugins/storage'

const ACCESS_TOKEN_KEY = "access_token";

const TokenService = {
        storage.get(ACCESS_TOKEN_KEY).then(v => {
            return v
    async saveAccessToken(accessToken: string) {
        storage.set(ACCESS_TOKEN_KEY, accessToken);

export { TokenService };


import { Storage, Drivers } from '@ionic/storage'

const localStorage = new Storage()

const storage = {
    set: async(i: any, v: any) => {
        await localStorage.set(i, v)
    get(i: any){
        return localStorage.get(i)
    remove: async (i: any) => {
        await localStorage.remove(i);
    clear: async () => {
        await localStorage.clear();

export default storage

i only get undefined but when using console.log() inside the storage.ts i get the value but after the app started.

i also use this function to make a condition in /router/index.ts
when i was using localStorage i was getting the values well.

my dependencies:

    "@ionic-native/secure-storage": "^5.31.1",
    "@ionic/storage": "^3.0.4",
    "@ionic/vue": "^5.6.0-dev.202102221703.5300dcc",
    "@ionic/vue-router": "^5.6.0-dev.202102221703.5300dcc",
    "vue": "^3.0.0-0",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-rc.2",

What can i do?

should be, it is not a promise… ie not async

        return storage.get(ACCESS_TOKEN_KEY)

I get back Promise {} and in the main.ts i have to use .then() to get the value, do you know if theres a way to get the value directly with getAccessToken() ?, thats why i was using then() inside de getAccessToken() but i get undefined instead…


that returns a promise so it should be more like this I believe

    get =. async (i: any) => {
        return await localStorage.get(i)