Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions packages/dev/docs/pages/react-spectrum/ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,14 @@ Media queries and DOM feature detection cannot be performed on the server becaus
Add the following to your `next.config.js` file. This will ensure that React Spectrum’s CSS is loaded properly by Next.js.

```tsx
import glob from 'glob';

module.exports = {
transpilePackages: [
"@adobe/react-spectrum",
"@react-spectrum/*",
"@spectrum-icons/*",
].flatMap((spec) => glob.sync(`${spec}`, { cwd: "node_modules/" })),
'@adobe/react-spectrum',
'@react-spectrum/*',
'@spectrum-icons/*',
].flatMap((spec) => glob.sync(`${spec}`, { cwd: 'node_modules/' })),
};
```

Expand All @@ -317,11 +319,13 @@ yarn add next-transpile-modules
With this installed, add the following to your `next.config.js` file.

```tsx
const withTM = require("next-transpile-modules")([
"@adobe/react-spectrum",
"@react-spectrum/*",
"@spectrum-icons/*",
].flatMap((spec) => glob.sync(`${spec}`, { cwd: "node_modules/" })));
const glob = require('glob');

const withTM = require('next-transpile-modules')([
'@adobe/react-spectrum',
'@react-spectrum/*',
'@spectrum-icons/*',
].flatMap((spec) => glob.sync(`${spec}`, { cwd: 'node_modules/' })));

module.exports = withTM({
// Your Next.js configuration
Expand All @@ -336,4 +340,22 @@ module.exports = withTM({

## Remix

[Remix](https://remix.run) is a full-stack React framework with nested routing. To configure Remix to load React Spectrum styles, visit the [CSS Side-Effect Imports](https://remix.run/docs/en/main/guides/styling#md-css-side-effect-imports) section of the Remix docs.
[Remix](https://remix.run) is a full-stack React framework with nested routing.

To configure Remix to load React Spectrum styles, CSS Side-Effect Imports is required, and [Remix Vite](https://remix.run/docs/en/main/future/vite) has built-in support for it.

However, to make it work with SSR, a small amount of configuration is required. Add the following to your `vite.config.js` or `vite.config.ts` file. This will ensure that React Spectrum’s CSS can be built properly.

```tsx
import glob from 'glob';

export default defineConfig({
ssr: {
noExternal: [
'@adobe/react-spectrum',
'@react-spectrum/*',
'@spectrum-icons/*',
].flatMap((spec) => glob.sync(`${spec}`, { cwd: 'node_modules/' })),
}
});
```