[docs] JSX framework integration READMEs (#8151)
This commit is contained in:
parent
767eb68666
commit
15471e6b4f
3 changed files with 104 additions and 0 deletions
|
@ -115,6 +115,42 @@ Check out the [`pnpm` overrides](https://pnpm.io/package_json#pnpmoverrides) and
|
||||||
> **Note**
|
> **Note**
|
||||||
> Currently, the `compat` option only works for React libraries that export code as ESM. If an error happens during build-time, try adding the library to `vite.ssr.noExternal: ['the-react-library']` in your `astro.config.mjs` file.
|
> Currently, the `compat` option only works for React libraries that export code as ESM. If an error happens during build-time, try adding the library to `vite.ssr.noExternal: ['the-react-library']` in your `astro.config.mjs` file.
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
### Combining multiple JSX frameworks
|
||||||
|
|
||||||
|
When you are using multiple JSX frameworks (React, Preact, Solid) in the same project, Astro needs to determine which JSX framework-specific transformations should be used for each of your components. If you have only added one JSX framework integration to your project, no extra configuration is needed.
|
||||||
|
|
||||||
|
Use the `include` (required) and `exclude` (optional) configuration options to specify which files belong to which framework. Provide an array of files and/or folders to `include` for each framework you are using. Wildcards may be used to include multiple file paths.
|
||||||
|
|
||||||
|
We recommend placing common framework components in the same folder (e.g. `/components/react/` and `/components/solid/`) to make specifying your includes easier, but this is not required:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import preact from '@astrojs/preact';
|
||||||
|
import react from '@astrojs/react';
|
||||||
|
import svelte from '@astrojs/svelte';
|
||||||
|
import vue from '@astrojs/vue';
|
||||||
|
import solid from '@astrojs/solid-js';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
// Enable many frameworks to support all different kinds of components.
|
||||||
|
// No `include` is needed if you are only using a single JSX framework!
|
||||||
|
integrations: [
|
||||||
|
preact({
|
||||||
|
include: ['**/preact/*']
|
||||||
|
}),
|
||||||
|
react({
|
||||||
|
include: ['**/react/*']
|
||||||
|
}),
|
||||||
|
solid({
|
||||||
|
include: ['**/solid/*'],
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
- The [Astro Preact example](https://github.com/withastro/astro/tree/latest/examples/framework-preact) shows how to use an interactive Preact component in an Astro project.
|
- The [Astro Preact example](https://github.com/withastro/astro/tree/latest/examples/framework-preact) shows how to use an interactive Preact component in an Astro project.
|
||||||
|
|
|
@ -63,6 +63,39 @@ To use your first React component in Astro, head to our [UI framework documentat
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
|
### Combining multiple JSX frameworks
|
||||||
|
|
||||||
|
When you are using multiple JSX frameworks (React, Preact, Solid) in the same project, Astro needs to determine which JSX framework-specific transformations should be used for each of your components. If you have only added one JSX framework integration to your project, no extra configuration is needed.
|
||||||
|
|
||||||
|
Use the `include` (required) and `exclude` (optional) configuration options to specify which files belong to which framework. Provide an array of files and/or folders to `include` for each framework you are using. Wildcards may be used to include multiple file paths.
|
||||||
|
|
||||||
|
We recommend placing common framework components in the same folder (e.g. `/components/react/` and `/components/solid/`) to make specifying your includes easier, but this is not required:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import preact from '@astrojs/preact';
|
||||||
|
import react from '@astrojs/react';
|
||||||
|
import svelte from '@astrojs/svelte';
|
||||||
|
import vue from '@astrojs/vue';
|
||||||
|
import solid from '@astrojs/solid-js';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
// Enable many frameworks to support all different kinds of components.
|
||||||
|
// No `include` is needed if you are only using a single JSX framework!
|
||||||
|
integrations: [
|
||||||
|
preact({
|
||||||
|
include: ['**/preact/*']
|
||||||
|
}),
|
||||||
|
react({
|
||||||
|
include: ['**/react/*']
|
||||||
|
}),
|
||||||
|
solid({
|
||||||
|
include: ['**/solid/*'],
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Children parsing
|
### Children parsing
|
||||||
|
|
||||||
Children passed into a React component from an Astro component are parsed as plain strings, not React nodes.
|
Children passed into a React component from an Astro component are parsed as plain strings, not React nodes.
|
||||||
|
|
|
@ -61,6 +61,41 @@ To use your first SolidJS component in Astro, head to our [UI framework document
|
||||||
- 💧 client-side hydration options, and
|
- 💧 client-side hydration options, and
|
||||||
- 🤝 opportunities to mix and nest frameworks together
|
- 🤝 opportunities to mix and nest frameworks together
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
### Combining multiple JSX frameworks
|
||||||
|
|
||||||
|
When you are using multiple JSX frameworks (React, Preact, Solid) in the same project, Astro needs to determine which JSX framework-specific transformations should be used for each of your components. If you have only added one JSX framework integration to your project, no extra configuration is needed.
|
||||||
|
|
||||||
|
Use the `include` (required) and `exclude` (optional) configuration options to specify which files belong to which framework. Provide an array of files and/or folders to `include` for each framework you are using. Wildcards may be used to include multiple file paths.
|
||||||
|
|
||||||
|
We recommend placing common framework components in the same folder (e.g. `/components/react/` and `/components/solid/`) to make specifying your includes easier, but this is not required:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import preact from '@astrojs/preact';
|
||||||
|
import react from '@astrojs/react';
|
||||||
|
import svelte from '@astrojs/svelte';
|
||||||
|
import vue from '@astrojs/vue';
|
||||||
|
import solid from '@astrojs/solid-js';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
// Enable many frameworks to support all different kinds of components.
|
||||||
|
// No `include` is needed if you are only using a single JSX framework!
|
||||||
|
integrations: [
|
||||||
|
preact({
|
||||||
|
include: ['**/preact/*']
|
||||||
|
}),
|
||||||
|
react({
|
||||||
|
include: ['**/react/*']
|
||||||
|
}),
|
||||||
|
solid({
|
||||||
|
include: ['**/solid/*'],
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
|
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
|
||||||
|
|
Loading…
Reference in a new issue