@@ -31,25 +31,36 @@ export function useSettings() {
3131 return useContext ( SettingsContext ) ;
3232}
3333
34+ const defaultSettings = {
35+ explorer : 'solana-explorer' as Explorer ,
36+ priorityFee : 'low' as PriorityFee ,
37+ rpcType : 'default' as RpcType ,
38+ customRpcUrl : '' ,
39+ } ;
40+
3441export function SettingsProvider ( { children } : { children : ReactNode } ) {
3542 const [ explorer , setExplorer ] = useState < Explorer > ( ( ) => {
43+ if ( typeof window === 'undefined' ) return defaultSettings . explorer ;
3644 const saved = localStorage . getItem ( 'explorer' ) as Explorer ;
37- return saved || 'solana- explorer' ;
45+ return saved || defaultSettings . explorer ;
3846 } ) ;
3947
4048 const [ priorityFee , setPriorityFee ] = useState < PriorityFee > ( ( ) => {
49+ if ( typeof window === 'undefined' ) return defaultSettings . priorityFee ;
4150 const saved = localStorage . getItem ( 'priority-fee' ) as PriorityFee ;
42- return saved || 'low' ;
51+ return saved || defaultSettings . priorityFee ;
4352 } ) ;
4453
4554 const [ rpcType , setRpcType ] = useState < RpcType > ( ( ) => {
55+ if ( typeof window === 'undefined' ) return defaultSettings . rpcType ;
4656 const saved = localStorage . getItem ( 'rpc-type' ) as RpcType ;
47- return saved || 'default' ;
57+ return saved || defaultSettings . rpcType ;
4858 } ) ;
4959
5060 const [ customRpcUrl , setCustomRpcUrl ] = useState < string > ( ( ) => {
61+ if ( typeof window === 'undefined' ) return defaultSettings . customRpcUrl ;
5162 const saved = localStorage . getItem ( 'custom-rpc-url' ) ;
52- return saved || '' ;
63+ return saved || defaultSettings . customRpcUrl ;
5364 } ) ;
5465
5566 useEffect ( ( ) => {
0 commit comments