just-tron-auth
v0.1.27
Published
A simple authentication library for Tron dApps
Downloads
294
Maintainers
Readme
Just Auth
A simple authentication library for Tron dApps.
Details developer docs can be found at: https://just-auth.gitbook.io
Installation
npm install just-tron-auth
import { JustAuthProvider } from 'just-tron-auth';
function App() {
return (
<JustAuthProvider appId="your-app-id">
<YourApp />
</JustAuthProvider>
);
}
import { useJustAuth } from 'just-tron-auth';
function YourComponent() {
const { isAuthenticated, userAddress, openAuthModal, signMessage, exportPrivateKey, logout } = useJustAuth();
if (!isAuthenticated) {
return <button onClick={openAuthModal}>Login</button>;
}
return (
<div>
<p>Welcome, {userAddress}</p>
<button onClick={() => signMessage('Hello, World!')}>Sign Message</button>
<button onClick={exportPrivateKey}>Export Private Key</button>
<button onClick={logout}>Logout</button>
</div>
);
}