Skip to content

Commit dcb3251

Browse files
authored
chore(docs): Update troubleshooting guide to show SSR error (#5709)
1 parent 2e3d373 commit dcb3251

File tree

1 file changed

+42
-29
lines changed

1 file changed

+42
-29
lines changed

docs/src/pages/[platform]/getting-started/troubleshooting/troubleshooting.react.mdx

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ This is a known problem when using the `jsdom` library (a dependency of Jest) wi
170170

171171
### Next 13.4+: React Server Components
172172

173-
Next.js 13.4+ introduces [app directory](https://nextjs.org/docs/app/building-your-application/routing#the-app-directory) with the usage of [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components). To use Amplify UI componenents, you must use them inside the Client Component tree by placing `"use client"` at the boundary between your Client and Server component module graph. Please see the Next.js [documentation](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#using-third-party-packages-and-providers) on how you could achieve this.
173+
Next.js 13.4+ introduces [app directory](https://nextjs.org/docs/app/building-your-application/routing#the-app-directory) with the usage of [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components). Amplify UI components are intended to be used on the client side. See [here](#attempted-import-error-useform-is-not-exported-from-react-hook-form-imported-as-useform) for solutions.
174174

175175
### Next 13.4+: `Module not found` Errors
176176

@@ -186,6 +186,47 @@ Module not found: Can't resolve 'aws-crt' in 'xxx'
186186

187187
These errors will not affect the use and functionality of the client, nor will errors appear in the browser console. This is a known transitive issue when using the AWS SDK. The issue is currently tracked [here](https://github.com/aws-amplify/amplify-js/issues/11030).
188188

189+
## Server-Side Rendering (SSR)
190+
191+
### Attempted import error: 'useForm' is not exported from 'react-hook-form' (imported as 'useForm').
192+
193+
If you attempt to use Amplify with server-side rendering, you may encounter the following error:
194+
195+
```
196+
./node_modules/@aws-amplify/ui-react-core/dist/esm/components/FormCore/FormProvider.mjs
197+
Attempted import error: 'useForm' is not exported from 'react-hook-form' (imported as 'useForm').
198+
```
199+
200+
Amplify UI components are interactive and designed to work on the client side. To use them inside of Server Components you must wrap them in a Client Component with "use client". For more information, see the Next.js [documentation](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#using-third-party-packages-and-providers) on how you could achieve this.
201+
202+
## Vite
203+
204+
### `Uncaught ReferenceError: global is not defined`
205+
206+
<Message
207+
variation="filled"
208+
colorTheme="info"
209+
>
210+
Note: this issue was fixed in `aws-amplify` version 6
211+
</Message>
212+
213+
When working with a [Vite](https://vitejs.dev) project you must make a few modifications. Please follow the steps below.
214+
215+
<Tabs.Container defaultValue="TypeScript">
216+
<Tabs.List>
217+
<Tabs.Item value="TypeScript">TypeScript</Tabs.Item>
218+
<Tabs.Item value="JavaScript">JavaScript</Tabs.Item>
219+
</Tabs.List>
220+
<Tabs.Panel value="TypeScript">
221+
<VitePolyfillTS />
222+
</Tabs.Panel>
223+
<Tabs.Panel value="JavaScript">
224+
<VitePolyfill />
225+
</Tabs.Panel>
226+
</Tabs.Container>
227+
228+
> If you are still having issues, please see comments on the following issue for additional [Vite workarounds](https://github.com/aws-amplify/amplify-js/issues/9639). Note that there is active ongoing work to make these modifications unnecessary.
229+
189230
## Webpack
190231

191232
### Webpack 5+: `Uncaught ReferenceError: process is not defined`
@@ -229,31 +270,3 @@ Follow the instructions below if you are using Webpack 5:
229270

230271
Follow [here](#cra-4-cant-import-the-named-export-amplify-from-non-ecmascript-module-only-default-export-is-available) for solutions.
231272

232-
233-
## Vite
234-
235-
### `Uncaught ReferenceError: global is not defined`
236-
237-
<Message
238-
variation="filled"
239-
colorTheme="info"
240-
>
241-
Note: this issue was fixed in `aws-amplify` version 6
242-
</Message>
243-
244-
When working with a [Vite](https://vitejs.dev) project you must make a few modifications. Please follow the steps below.
245-
246-
<Tabs.Container defaultValue="TypeScript">
247-
<Tabs.List>
248-
<Tabs.Item value="TypeScript">TypeScript</Tabs.Item>
249-
<Tabs.Item value="JavaScript">JavaScript</Tabs.Item>
250-
</Tabs.List>
251-
<Tabs.Panel value="TypeScript">
252-
<VitePolyfillTS />
253-
</Tabs.Panel>
254-
<Tabs.Panel value="JavaScript">
255-
<VitePolyfill />
256-
</Tabs.Panel>
257-
</Tabs.Container>
258-
259-
> If you are still having issues, please see comments on the following issue for additional [Vite workarounds](https://github.com/aws-amplify/amplify-js/issues/9639). Note that there is active ongoing work to make these modifications unnecessary.

0 commit comments

Comments
 (0)