For the complete documentation index, see llms.txt
Skip to main content

Feedback widget for Docusaurus

Add the PushFeedback widget in a Docusaurus project using the official plugin.

Prerequisites​

  • A PushFeedback project. Copy its project ID from Projects > your project > Snippet and replace <YOUR_PROJECT_ID> in the examples.
  • A Docusaurus site and Node.js installed.

For a floating button, use docusaurus-pushfeedback 1.0.9 on Docusaurus 3 or 0.1.7 on Docusaurus 2. Other modes use pushfeedback-react 0.1.76.

The examples load the widget runtime from jsDelivr and import the installed stylesheet. For a local runtime, see self-hosted assets.

Installation​

Floating button​

Example page with a floating Feedback button on the right edge

  1. Install PushFeedback:

    npm install [email protected]

  2. Add the plugin to your Docusaurus config file docusaurus.config.js:

    plugins: [
    [
    'docusaurus-pushfeedback',{
    project: '<YOUR_PROJECT_ID>'
    }
    ]
    ],

    Replace <YOUR_PROJECT_ID> with your project's ID from the PushFeedback dashboard.

  3. Open your site. Click Feedback to check that the form opens.

Customization​

You can change the widget's position, color, and more. Add any configuration and text option to the plugin, formatted as camelCase.

Here's an example:

plugins: [
[
'docusaurus-pushfeedback',{
project: '<YOUR_PROJECT_ID>',
buttonPosition: 'center-right',
modalPosition: 'sidebar-right',
buttonStyle: 'dark',
modalTitle: 'Share your thoughts'
}
]
],

Set CSS custom properties in your existing Docusaurus custom stylesheet. See Docusaurus custom CSS if the site has no stylesheet yet.

Other installation modes​

Inline button​

Feedback button placed within page content

  1. Install the React widget package:

  2. Run npm run swizzle @docusaurus/theme-classic DocItem/Footer and choose Wrap. Replace src/theme/DocItem/Footer/index.js with:

    import React, { useEffect } from 'react';
    import Footer from '@theme-original/DocItem/Footer';
    import { FeedbackButton } from 'pushfeedback-react';

    import 'pushfeedback/dist/pushfeedback/pushfeedback.css';

    function PageFeedback() {
    useEffect(() => {
    if (document.querySelector('script[data-pushfeedback]')) return;
    const script = document.createElement('script');
    script.type = 'module';
    script.src =
    'https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js';
    script.dataset.pushfeedback = '';
    document.head.appendChild(script);
    }, []);
    return (
    <FeedbackButton
    project="<YOUR_PROJECT_ID>"
    button-position="default"
    modal-position="center"
    button-style="dark"
    >
    Feedback
    </FeedbackButton>
    );
    }

    export default function FooterWrapper(props) {
    return (
    <>
    <Footer {...props} />
    <PageFeedback />
    </>
    );
    }

This wrapper loads the stylesheet and custom elements and places the widget after each document. Remove docusaurus-pushfeedback from your config if you do not want its floating button.

Embedded form​

Feedback form embedded directly in a page

  1. Install the React widget package:

  2. Run npm run swizzle @docusaurus/theme-classic DocItem/Footer and choose Wrap. Replace src/theme/DocItem/Footer/index.js with:

    import React, { useEffect } from 'react';
    import Footer from '@theme-original/DocItem/Footer';
    import { FeedbackModal } from 'pushfeedback-react';

    import 'pushfeedback/dist/pushfeedback/pushfeedback.css';

    function PageFeedback() {
    useEffect(() => {
    if (document.querySelector('script[data-pushfeedback]')) return;
    const script = document.createElement('script');
    script.type = 'module';
    script.src =
    'https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js';
    script.dataset.pushfeedback = '';
    document.head.appendChild(script);
    }, []);
    return <FeedbackModal project="<YOUR_PROJECT_ID>" embedded="true" />;
    }

    export default function FooterWrapper(props) {
    return (
    <>
    <Footer {...props} />
    <PageFeedback />
    </>
    );
    }

This wrapper loads the stylesheet and custom elements and places the widget after each document. Remove docusaurus-pushfeedback from your config if you do not want its floating button.

Like and dislike buttons​

Inline Helpful and Not helpful rating buttons

  1. Install the published widget and React wrapper:

  2. Run npm run swizzle @docusaurus/theme-classic DocItem/Footer and choose Wrap. Replace src/theme/DocItem/Footer/index.js with:

    import React, { useEffect } from 'react';
    import Footer from '@theme-original/DocItem/Footer';
    import { FeedbackButton } from 'pushfeedback-react';

    import 'pushfeedback/dist/pushfeedback/pushfeedback.css';

    export default function FooterWrapper(props) {
    useEffect(() => {
    if (document.querySelector('script[data-pushfeedback]')) return;
    const script = document.createElement('script');
    script.type = 'module';
    script.src =
    'https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js';
    script.dataset.pushfeedback = '';
    document.head.appendChild(script);
    }, []);
    return (
    <>
    <Footer {...props} />
    <p>Was this helpful?</p>
    <FeedbackButton
    project="<YOUR_PROJECT_ID>"
    rating="1"
    button-position="default"
    modal-position="center"
    button-style="light"
    >
    Helpful
    </FeedbackButton>
    <FeedbackButton
    project="<YOUR_PROJECT_ID>"
    rating="0"
    button-position="default"
    modal-position="center"
    button-style="light"
    >
    Not helpful
    </FeedbackButton>
    </>
    );
    }

Each button opens the form with its rating selected. The visitor still clicks Send to submit. Remove docusaurus-pushfeedback from your config if you want only these buttons.

Advanced setup: Multilingual support​

Widget title, button, and send action in Spanish

With Docusaurus i18n enabled:

  1. Install the widget packages:

  2. Run npm run swizzle @docusaurus/theme-classic Footer and choose Wrap. Replace src/theme/Footer/index.js with:

    import React, { useEffect } from 'react';
    import Footer from '@theme-original/Footer';
    import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
    import { FeedbackButton } from 'pushfeedback-react';

    import 'pushfeedback/dist/pushfeedback/pushfeedback.css';

    const labels = {
    en: { button: 'Feedback', title: 'Share your feedback', send: 'Send' },
    es: { button: 'Sugerencias', title: 'Danos tu opinión', send: 'Enviar' },
    };

    export default function FooterWrapper(props) {
    const { i18n } = useDocusaurusContext();
    const text = labels[i18n.currentLocale] || labels.en;
    useEffect(() => {
    if (document.querySelector('script[data-pushfeedback]')) return;
    const script = document.createElement('script');
    script.type = 'module';
    script.src =
    'https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js';
    script.dataset.pushfeedback = '';
    document.head.appendChild(script);
    }, []);
    return (
    <>
    <Footer {...props} />
    <FeedbackButton
    project="<YOUR_PROJECT_ID>"
    button-position="bottom-right"
    button-style="dark"
    modal-title={text.title}
    send-button-text={text.send}
    >
    {text.button}
    </FeedbackButton>
    </>
    );
    }

Replace the project ID and add your languages to labels. This example translates the button, title, and send action. Add the remaining labels from Text to translate the full form. Remove docusaurus-pushfeedback from your config if you want only this button.

Verify the installation​

Run npm run build, then npm run serve. Open a document, send a test message, and confirm it appears in your PushFeedback project. For multilingual sites, check each locale. Check allowed URLs if submission fails.