Skip to content

Instantly share code, notes, and snippets.

@ademilter
Created April 25, 2022 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademilter/975343a47bce6a4e586b7cde46b946ae to your computer and use it in GitHub Desktop.
Save ademilter/975343a47bce6a4e586b7cde46b946ae to your computer and use it in GitHub Desktop.
@upstash/chatbox
// pages/api/chatbox/[...chatbox].js
import createChatBoxAPI from "@upstash/chatbox/api";
const ChatBoxAPI = createChatBoxAPI({
webhooks: [process.env.SLACK_WEBHOOK_URL!],
});
export default ChatBoxAPI;
// pages/_app.jsx
import "@upstash/chatbox/index.css";
import { AppProps } from "next/app";
import dynamic from "next/dynamic";
const ChatBoxWidget = dynamic({
loader: () => import("@upstash/chatbox").then((mod) => mod.ChatBoxWidget),
ssr: false,
});
export default function App(props: AppProps) {
const { Component, pageProps } = props;
return (
<>
<ChatBoxWidget />
<Component {...pageProps} />
</>
);
}
// pages/chat/[id].jsx
import dynamic from "next/dynamic";
const ChatBoxAdmin = dynamic({
loader: () => import("@upstash/chatbox").then((mod) => mod.ChatBoxAdmin),
ssr: false,
});
export default function () {
return <ChatBoxAdmin />;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment