diff --git a/src/useHistory.ts b/src/useHistory.ts index 1f83335..b257bc1 100644 --- a/src/useHistory.ts +++ b/src/useHistory.ts @@ -22,8 +22,10 @@ function patchHistoryMethod(method: PathMethod): void { ) } -patchHistoryMethod('pushState') -patchHistoryMethod('replaceState') +if (typeof window !== 'undefined') { + patchHistoryMethod('pushState') + patchHistoryMethod('replaceState') +} export interface IHistoryState { state: any