diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..7549ed2 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +# Redux Persistence Location +VITE_REDUX_STORAGE=local \ No newline at end of file diff --git a/src/layout/hero-layout/index.tsx b/src/layout/hero-layout/index.tsx index 760217e..04a446b 100644 --- a/src/layout/hero-layout/index.tsx +++ b/src/layout/hero-layout/index.tsx @@ -45,7 +45,7 @@ export default function HeroLayout() { {/* Main Content Area */} -
+
diff --git a/src/store/index.ts b/src/store/index.ts index 8517872..2ee3a4f 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -10,10 +10,11 @@ import { PURGE, REGISTER, } from "redux-persist" -import storage from "redux-persist/lib/storage/session" // use session storage -// import storage from "redux-persist/lib/storage" // use local storage +import createWebStorage from "redux-persist/es/storage/createWebStorage" import authReducer from "./auth-slice" +const storage = createWebStorage(import.meta.env.VITE_REDUX_STORAGE ?? "local") + const persistConfig = { key: "root", storage, diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 391fbdf..d0d19dd 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,6 +1,6 @@ /// interface ImportMetaEnv { - // todo add env properties here + readonly VITE_REDUX_STORAGE: "local" | "session" } interface ImportMeta {