UNPKG

@nerdlat/auth

Version:

Authentication library similar to Clerk for React and Express applications

17 lines (16 loc) 668 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserProfile = UserProfile; const jsx_runtime_1 = require("react/jsx-runtime"); const authApi_1 = require("./authApi"); const useAuth_1 = require("./useAuth"); function UserProfile() { const { user, setUser } = (0, useAuth_1.useAuth)(); const handleLogout = async () => { await (0, authApi_1.logout)(); setUser(null); }; if (!user) return null; return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { children: user.email }), (0, jsx_runtime_1.jsx)("button", { onClick: handleLogout, children: "Logout" })] })); }