@stackso/nextjs
v0.0.3
Published
Stack SDK for Next.js applications
Downloads
4
Keywords
Readme
@stackso/nextjs
@stackso/nextjs provides a nextjs + react wrapper for the Stack API.
Install packages
pnpm i @stackso/core @stackso/nextjs
Usage
Set environment variables:
NEXT_PUBLIC_STACK_API_KEY=<stack api key>
NEXT_PUBLIC_STACK_API_URL=<stack url>
To setup the stack provider:
import { StackProvider } from '@stackso/nextjs'
function App() {
return (
<StackProvider>
<YourRoutes />
</StackProvider>
)
}
Hooks usage:
import { useSignup } from '@stackso/nextjs'
function App() {
const { signup, isLoading, isSuccess } = useSignup();
const { email, setEmail } = useState<string>("");
const { password, setPassword } = useState<string>("");
const handleSignup = async (event) => {
// Handle event
await signup({
email,
password
});
// Handle success
};
return (
{ /* other components here */ }
<button
onClick={handleSignup}
>
Signup
</button>
);
}