Appmaker WebSDK
The Appmaker Web SDK is a JavaScript library that allows you to interact with the Appmaker webview.
Requirements
This library is only compatible with the Appmaker webview.
Installation
There are two ways to install the Appmaker Web SDK:
- Create a single page React app and then connect with appmaker web SDK
- Connect existing page with appmaker web SDK using script https://unpkg.com/@appmaker-xyz/web-sdk@latest/dist/index.umd.js
Configure the Appmaker Web SDK using React
Create a sample react app using next.js. You can use the following command to create a sample react app.
npx create-next-app my-app
cd my-appStart the development server using the following command.
npm start
You can see the sample app running on http://localhost:3000
Now you can edit the
src\App.js
of the my-app project and add your custom code.
For example, you can simply add a button to the src\App.js
file.
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<button>Open Cart</button>
</header>
</div>
);
}
export default App;
save the file and you can see the button on the page.
Now you can add the Appmaker Web SDK to the project. You can use the following command to install the Appmaker Web SDK.
npm install @appmaker-xyz/web-sdk
Import the Appmaker Web SDK in the
src\App.js
file.import AppmakerWebSDK from "@appmaker-xyz/web-sdk";
Let's add an action to button to open the cart.
import logo from './logo.svg';
import './App.css';
import AppmakerWebSDK from "@appmaker-xyz/web-sdk";
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
p>
Edit <code>src/App.js</code> and save to reload.
</p>
<button onClick={() => AppmakerWebSDK.openCart()}>Open Cart</button>
</header>
</div>
);
}
export default App;Now when you click on open cart button from the appmaker webview it will open the cart.
You can also refer to another example here.
Configure the Appmaker Web SDK using script
Create a sample html page and add the following script tag to the page.
<script src="https://unpkg.com/@appmaker-xyz/web-sdk@latest/dist/index.umd.js"></script>
Now you can use the Appmaker Web SDK in the page.
<script>
AppmakerWebSDK.openCart();
</script>Now when you open the page from the appmaker webview it will open the cart.
You can also hide header and footer of a page using appmaker web SDK , refer to the example here.
Appmaker WebSDK Methods
To know more about appmaker web SDK and it's methods, refer to the documentation.