markdown-to-jsx 9.4.2 → 9.5.0

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 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: