eigent/package/@stackframe/react/dist/esm/lib/hooks.js
2025-08-12 01:16:39 +02:00

30 lines
No EOL
1,002 B
JavaScript

// src/lib/hooks.tsx
import { useContext } from "react";
import { StackContext } from "../providers/stack-provider-client";
function useUser(options = {}) {
const stackApp = useStackApp(options);
if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
}
if (options.projectIdMustMatch === "internal") {
return stackApp.useUser(options);
} else {
return stackApp.useUser(options);
}
}
function useStackApp(options = {}) {
const context = useContext(StackContext);
if (context === null) {
throw new Error("useStackApp must be used within a StackProvider");
}
const stackApp = context.app;
if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
}
return stackApp;
}
export {
useStackApp,
useUser
};
//# sourceMappingURL=hooks.js.map