@gately/nextjs
v2.3.5
Published
Next.js SDK for Gately - built on @gately/react
Downloads
1,523
Maintainers
Readme
@gately/nextjs
Official Next.js SDK for Gately — authentication and user management with App Router, Server Components, and middleware support.
Installation
npm install @gately/nextjsQuick Start
// app/layout.tsx
import { GatelyProvider } from '@gately/nextjs';
export default function RootLayout({ children }) {
return (
<html>
<body>
<GatelyProvider projectId="your-project-id">
{children}
</GatelyProvider>
</body>
</html>
);
}
// Any client component
'use client';
import { useGately } from '@gately/nextjs';
export function Profile() {
const { user, isAuthenticated, logout } = useGately();
if (!isAuthenticated) return <p>Not logged in</p>;
return (
<div>
<p>Welcome, {user?.email}</p>
<button onClick={logout}>Logout</button>
</div>
);
}Features
- Full App Router support
- Server Components compatible
- Middleware for route protection
- Built-in session management
- OAuth and social login
- Type-safe with TypeScript
- SSR-safe initialization
Middleware Example
// middleware.ts
import { withGatelyAuth } from '@gately/nextjs';
export const middleware = withGatelyAuth((req) => {
// Your logic here
});
export const config = {
matcher: ['/dashboard/:path*', '/api/protected/:path*'],
};Documentation
For complete documentation and examples, visit:
https://usegately.com/docs/sdk/nextjs
Built On
This SDK is built on @gately/react, which uses @gately/gately-js.
