initialize
After installing the package, we need to create an instance of Metastaq SDK with the required parameters. Follow the link for more details.
Metastaq Provider
Import metastaq provider using import { MetaStaqProvider } from 'metastaq-sdk'
and wrap your application in it, your app.js file in src/app.js
should look something like this.
src/app.js
import React from "react";
import { MetaStaqProvider } from "metastaq-sdk";
import { Home } from ".components/Home";
const App = () => {
return (
<MetaStaqProvider>
<Home />
</MetaStaqProvider>
);
};
export default App;
Metastaq Instance
import { MetaStaqStoreFrontSdk } from "metastaq-sdk";
import { CLIENT_ID, RELEASE_ID } from "./constants";
export const MetastaqInstance = new MetaStaqStoreFrontSdk(
// your projects client id
CLIENT_ID, //*required
// Release id of project
RELEASE_ID, //*required
// project's environment type
"testing" // available options ["testing", "staging"], don't add any env type for production
);
After successfully initializing the SDK, we can import and use methods
const { fetchCollection } = MetastaqInstance;
const data = fetchCollection("params");