From 74b4ae30f9adc77972e1e3d4080e87771fb6da3e Mon Sep 17 00:00:00 2001
From: Alex
Date: Sat, 12 Sep 2026 12:15:08 +0100
Subject: [PATCH 1/3] fix(react-widget): drop the stranded 'use client'
directive
Parcel's library build concatenates modules, so the directive at the top
of DocsGPTWidget.tsx landed a thousand lines into dist/module.js and
dist/main.js. webpack rejects a 'use client' that is not the first
expression in the file, which broke every Next.js consumer of
docsgpt-react:
x The "use client" directive must be placed before other expressions.
1168 | 'use client';
The directive could not do its job from inside a bundle anyway. A React
Server Components boundary has to be declared by the importing module,
so consumers wrap the widget in their own client component instead.
---
extensions/react-widget/src/components/DocsGPTWidget.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/extensions/react-widget/src/components/DocsGPTWidget.tsx b/extensions/react-widget/src/components/DocsGPTWidget.tsx
index 7af67307..94f09fd2 100644
--- a/extensions/react-widget/src/components/DocsGPTWidget.tsx
+++ b/extensions/react-widget/src/components/DocsGPTWidget.tsx
@@ -1,4 +1,3 @@
-'use client';
import React, { useRef } from 'react';
import DOMPurify from 'dompurify';
import styled, { keyframes, css } from 'styled-components';
From 3711426c83c1d8a2d0215c8a56afa2a2b3635042 Mon Sep 17 00:00:00 2001
From: Alex
Date: Sat, 12 Sep 2026 12:15:08 +0100
Subject: [PATCH 2/3] feat(docs): mount the DocsGPT chat widget
Adds a floating "Ask the docs" bubble to every docs page. docsgpt-react
was already a dependency but nothing imported it, so no widget rendered.
The widget reads window and navigator on mount, so it is lazy-loaded
with ssr: false from a client wrapper. Its light/dark theme follows the
site toggle via next-themes, promoted here from a transitive dependency
to a declared one.
The key comes from NEXT_PUBLIC_DOCSGPT_API_KEY and the host from
NEXT_PUBLIC_DOCSGPT_API_HOST. With no key set the wrapper renders
nothing rather than falling through to the demo key the package defaults
to.
Bumping docsgpt-react to ^0.7.0 also drops a duplicate React. The old
^0.6.3 pin depended on React 18 and npm installed a nested 18.3.1 beside
the app's 19.2.8, which would have thrown an invalid hook call on first
render.
---
docs/app/layout.jsx | 2 +
docs/components/DocsGPTChatWidget.jsx | 40 ++++++++++++++
docs/package-lock.json | 75 ++++-----------------------
docs/package.json | 3 +-
4 files changed, 55 insertions(+), 65 deletions(-)
create mode 100644 docs/components/DocsGPTChatWidget.jsx
diff --git a/docs/app/layout.jsx b/docs/app/layout.jsx
index 85911381..040d1781 100644
--- a/docs/app/layout.jsx
+++ b/docs/app/layout.jsx
@@ -5,6 +5,7 @@ import { getPageMap } from 'nextra/page-map';
import { Footer, Layout, Navbar } from 'nextra-theme-docs';
import 'nextra-theme-docs/style.css';
+import { DocsGPTChatWidget } from '../components/DocsGPTChatWidget';
import CuteLogo from '../public/cute-docsgpt.png';
import themeConfig from '../theme.config';
@@ -79,6 +80,7 @@ export default async function RootLayout({ children }) {
>
{children}
+