Getting started
/** Import Orbis SDK */
import { Orbis } from "@orbisclub/orbis-sdk";
/** Initialize the Orbis class object */
let orbis = new Orbis();Connecting to Ceramic
import React, { useState, useEffect } from 'react';
/** Import Orbis SDK */
import { Orbis } from "@orbisclub/orbis-sdk";
/**
* Initialize the Orbis class object:
* You can make this object available on other components by passing it as
* a prop or by using a context.
*/
let orbis = new Orbis();
export default function App() {
/** The user object returned by the connect function can be stored in state */
const [user, setUser] = useState();
/** Calls the Orbis SDK and handle the results */
async function connect() {
let res = await orbis.connect();
/** Check if connection is successful or not */
if(res.status == 200) {
setUser(res.did);
} else {
console.log("Error connecting to Ceramic: ", res);
alert("Error connecting to Ceramic.");
}
}
return(
<div>
{user ?
<p>Connected with: {user}</p>
:
<button onClick={() => connect()}>Connect</button>
}
</div>
)
}Next steps
Last updated