viewmo v0.2.0
Absolutely, here's the combined markdown code:
viewmo: A Chatbot UI for React and Next.js
viewmo is a comprehensive npm module designed to simplify the integration of chatbot functionality within your React and Next.js applications. It provides a robust and customizable <Chat>
component that streamlines the creation of user-friendly chat interfaces.
Installation
To incorporate viewmo into your project, simply utilize npm:
npm install viewmo
Usage
viewmo empowers you to seamlessly integrate a chat interface into your React application. Here's a step-by-step guide:
1. Secure Credential Management:
For enhanced security, viewmo leverages environment variables to store your chat credentials. Create a file named .env.local
at the root of your project. Inside this file, define the following environment variables, replacing the placeholders with your actual credentials:
REACT_APP_USERNAME=your_username
REACT_APP_PASSWORD=your_password
2. Importing and Utilizing the <Chat>
Component:
Within your React component, import the <Chat>
component from viewmo and leverage it as follows:
import React from 'react';
import Chat from 'viewmo';
const App = () => {
// Retrieve credentials securely from environment variables
const username = process.env.REACT_APP_USERNAME;
const password = process.env.REACT_APP_PASSWORD;
return (
<div>
<h1>Welcome to Your Chat Interface</h1>
<Chat username={username} password={password} />
</div>
);
};
export default App;
Explanation:
- We import React and Chat from viewmo.
- We securely retrieve the username and password from environment variables to safeguard sensitive information.
- We render the
<Chat>
component, passing the retrieved credentials as props to configure the chat functionality.
3. Comprehensive Example: Putting it All Together
The following example demonstrates the complete setup and usage of the <Chat>
component in your project:
import React from 'react';
import Chat from 'viewmo';
const App = () => {
// Retrieve credentials securely from environment variables
const username = process.env.REACT_APP_USERNAME;
const password = process.env.REACT_APP_PASSWORD;
return (
<div>
<h1>Welcome to Your Chat Interface</h1>
<Chat username={username} password={password} />
</div>
);
};
export default App;
Important Note:
Remember to create the .env.local
file at the project root and define the environment variables with your specific credentials:
REACT_APP_USERNAME=your_username
REACT_APP_PASSWORD=your_password
License
viewmo is released under the permissive MIT License.