npm install react react-dom next @sociably/core @sociably/http @sociably/webview # or with yarn yarn add react react-dom next @sociably/core @sociably/http @sociably/webview
constapp = Sociably.createApp({ modules: [ Http.initModule({/* ... */}), ], platforms: [ Messenger.initModule({/* ... */}), Webview.intiModule({ webviewHost:DOMAIN, webviewPath:'/webview', // have to match `basePath` in next.config.js authSecret:WEBVIEW_AUTH_SECRET, authPlatforms: [ // auth providers from platforms MessengerWebviewAuth, ], nextServerOptions: { dev:DEV, // use dev mode or not dir:'./webview', // the front-end app dir conf:nextConfigs, // import configs from next.config.js }, }), ], });
// webview/next.config.js module.exports = { distDir:'../dist', // the path of built front-end codes basePath:'/webview', // have to match `webviewPath` on back-end publicRuntimeConfig: { // export settings to front-end if needed messengerAppId:process.env.MESSENGER_APP_ID, }, };
Then you can use WebviewClient in the front-end pages like this:
Webview Platform
Serve webviews that integrated with the chat platforms.
This package combines three modules:
@sociably/auth
,@sociably/next
and@sociably/websocket
. You can use them separatedly if you don't need them all.Install
Docs
Check the Embedded Webview document and the API references.
Setup
Back-End
Assume you have the Next.js app directory at
./webview
, set up webview platform like this:You can create the front-end app with
npx create-next-app
if you don't have one.Front-End
Set up the Next.js app like this:
Then you can use
WebviewClient
in the front-end pages like this: