Video #08 · 1:24
How to add a chatbot to React, Next.js, Vue or Angular
If your website is a React, Next.js, Vue or Angular app, Install has the code for each. For Next.js you add two lines to your layout. For the others you save one file and add one tag. There is nothing to install: the chat loads from Aparsoft's servers.
What you need
- A website already added and read in Apar Chatbot
- Your app's source code (React, Next.js, Vue 3 or Angular)
Step by step
1Pick your framework's tab
Open Install. Under Where is your website built?, choose Something else, or my developer. Next to HTML/JavaScript there is a tab for React, Next.js, Vue and Angular. Each tab has the code with your website's key in it, and a short guide under it.

2React
Save the code as its own file, src/AparsoftChatbot.jsx. Then import it in App.jsx and render <AparsoftChatbot /> once. It draws nothing itself: the chat button appears on every page of the app.

3Next.js
Add the two marked lines to app/layout.js. The chat shows on every page.
// app/layout.js: add the two marked lines. The chat then shows on every page. import Script from 'next/script'; // add this line export default function RootLayout({ children }) { return ( <html lang="en"> <body> {children} <Script src="https://www.aparsoft.com/static/chatbot-widget/widget.loader.js" strategy="afterInteractive" data-aparsoft-chatbot="true" data-api-key="YOUR_WEBSITE_KEY" /> {/* add this line */} </body> </html> ); }
4Vue
Save the code as src/components/AparsoftChatbot.vue. Import it in App.vue and put <AparsoftChatbot /> once in its template. The file is written for Vue 3.

5Angular
Save the code as src/app/aparsoft-chatbot.component.ts. Add AparsoftChatbotComponent to your root component's imports, and <app-aparsoft-chatbot></app-aparsoft-chatbot> to its template. In an NgModule app, add it to the module's imports instead.

6Nothing to install
Each guide ends the same way: there is no package to add. The chat loads from Aparsoft's servers.

7Open your app
Here it is in a new Next.js app, saved and added just as the page says. The chat button is there, and it greets you.

Questions
Do I need to install an npm package?
No. The code loads the chat from Aparsoft's servers, so there is nothing to add to package.json.
Will it slow down my Next.js layout or make it a client component?
No. The chat loads after your page, and app/layout.js stays a server component.
Did you try these files in real apps?
Yes. Before filming, each file was saved and added as its guide says in a new app: Vite with React, Vite with Vue, Next.js with the App Router, and Angular. In each one the chat opened and greeted.
What about a plain HTML website, or WordPress?
On WordPress, search for "Apar Chatbot" in Plugins > Add New Plugin: Install has the steps. For plain HTML, choose Something else, or my developer.
Next guide
How to train a chatbot on your PDFs and documents