From 0187763c2947b71a31d059b1e32cb8074b473d01 Mon Sep 17 00:00:00 2001
From: Daniel Roe <daniel@roe.dev>
Date: Mon, 2 Jan 2023 00:18:05 +0100
Subject: [PATCH] refactor: set hydrated value in nuxt plugin

---
 composables/hydration.ts    | 7 -------
 plugins/hydration.client.ts | 5 +++++
 2 files changed, 5 insertions(+), 7 deletions(-)
 create mode 100644 plugins/hydration.client.ts

diff --git a/composables/hydration.ts b/composables/hydration.ts
index 98fad034..094b16cc 100644
--- a/composables/hydration.ts
+++ b/composables/hydration.ts
@@ -1,8 +1 @@
 export const isHydrated = ref(false)
-
-if (!process.server) {
-  const nuxtApp = useNuxtApp()
-  nuxtApp.hooks.hookOnce('app:suspense:resolve', () => {
-    isHydrated.value = true
-  })
-}
diff --git a/plugins/hydration.client.ts b/plugins/hydration.client.ts
new file mode 100644
index 00000000..7a7e7805
--- /dev/null
+++ b/plugins/hydration.client.ts
@@ -0,0 +1,5 @@
+export default defineNuxtPlugin((nuxtApp) => {
+  nuxtApp.hooks.hookOnce('app:suspense:resolve', () => {
+    isHydrated.value = true
+  })
+})