markdown-to-jsx 9.4.2 → 9.4.3-prerelease
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/html.cjs +86 -86
- package/dist/html.js +86 -86
- package/dist/html.js.map +3 -3
- package/dist/index.cjs +89 -89
- package/dist/index.js +89 -89
- package/dist/index.js.map +4 -4
- package/dist/markdown.cjs +91 -91
- package/dist/markdown.js +91 -91
- package/dist/markdown.js.map +3 -3
- package/dist/native.cjs +78 -78
- package/dist/native.js +78 -78
- package/dist/native.js.map +3 -3
- package/dist/react.cjs +89 -89
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +89 -89
- package/dist/react.js.map +4 -4
- package/dist/solid.cjs +80 -80
- package/dist/solid.js +79 -79
- package/dist/solid.js.map +3 -3
- package/dist/vue.cjs +72 -72
- package/dist/vue.js +72 -72
- package/dist/vue.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Some special features of the library:
|
|
|
25
25
|
- [Entry Points](#entry-points)
|
|
26
26
|
- [Main](#main)
|
|
27
27
|
- [React](#react)
|
|
28
|
+
- [React Server Components (RSC)](#react-server-components-rsc)
|
|
28
29
|
- [React Native](#react-native)
|
|
29
30
|
- [SolidJS](#solidjs)
|
|
30
31
|
- [Vue.js](#vuejs)
|
|
@@ -213,6 +214,40 @@ const ast = parser('# Hello world')
|
|
|
213
214
|
const jsxElement2 = astToJSX(ast)
|
|
214
215
|
```
|
|
215
216
|
|
|
217
|
+
##### React Server Components (RSC)
|
|
218
|
+
|
|
219
|
+
The `Markdown` component automatically detects whether it's running in a React Server Component (RSC) or client environment and adapts accordingly. No 'use client' directive is required.
|
|
220
|
+
|
|
221
|
+
**Server Component (RSC) usage:**
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
// Server Component - works automatically
|
|
225
|
+
import Markdown from 'markdown-to-jsx/react'
|
|
226
|
+
|
|
227
|
+
export default async function Page() {
|
|
228
|
+
const content = await fetchMarkdownContent()
|
|
229
|
+
return <Markdown>{content}</Markdown>
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Client Component usage:**
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
// Client Component - also works automatically
|
|
237
|
+
'use client'
|
|
238
|
+
import Markdown from 'markdown-to-jsx/react'
|
|
239
|
+
|
|
240
|
+
export function ClientMarkdown({ content }: { content: string }) {
|
|
241
|
+
return <Markdown>{content}</Markdown>
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Notes:**
|
|
246
|
+
- `MarkdownProvider` and `MarkdownContext` are client-only and become no-ops in RSC environments
|
|
247
|
+
- RSC rendering provides better performance by avoiding client-side hydration
|
|
248
|
+
- The component maintains identical output in both environments
|
|
249
|
+
- No migration needed for existing code
|
|
250
|
+
|
|
216
251
|
#### React Native
|
|
217
252
|
|
|
218
253
|
For React Native usage, import from the `/native` entry point:
|