Skip to content

Commit f05b30e

Browse files
committed
config+lib: updates to work with SSR apps like NextJS
1 parent c865242 commit f05b30e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/util/credentialStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ export default class LncCredentialStore implements CredentialStore {
189189

190190
/** Loads persisted data from localStorage */
191191
private _load() {
192+
// do nothing if localStorage is not available
193+
if (typeof localStorage === 'undefined') return;
194+
192195
try {
193196
const key = `${STORAGE_KEY}:${this.namespace}`;
194197
const json = localStorage.getItem(key);
@@ -202,6 +205,9 @@ export default class LncCredentialStore implements CredentialStore {
202205

203206
/** Saves persisted data to localStorage */
204207
private _save() {
208+
// do nothing if localStorage is not available
209+
if (typeof localStorage === 'undefined') return;
210+
205211
const key = `${STORAGE_KEY}:${this.namespace}`;
206212
localStorage.setItem(key, JSON.stringify(this.persisted));
207213
}

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
name: '@lightninglabs/lnc-web',
2929
type: "umd", // see https://webpack.js.org/configuration/output/#outputlibrarytype
3030
},
31+
globalObject: 'this',
3132
path: path.resolve(__dirname, 'dist'),
3233
},
3334
};

0 commit comments

Comments
 (0)