Version: @gately/nextjs@2.2.0
Features:
Features:
useGately hook, GatelyProvider, server utilities, route middleware, SSR supportInstallation
Quick Start
1. Create a Providers Component
BecauseGatelyProvider uses browser APIs, it must run client-side:
2. Add to Root Layout
3. Use in Client Components
4. Protect Pages with Middleware
GatelyProvider
useGately Hook
For use in'use client' components:
Server Utilities
Use in Server Components, Route Handlers, and Server Actions:getSession()
getUser()
isAuthenticated()
API Route Handler
Middleware
gatelyMiddleware
Supports two calling styles: Direct (recommended):MiddlewareConfig
Login Page
Environment Variables
TypeScript
Troubleshooting
window is not defined
window is not defined
GatelyProvider must be inside a 'use client' component. See the Providers setup above — never import it directly in a Server Component.useGately is not a function
useGately is not a function
Ensure you’re on
@gately/nextjs@1.0.2. Run:Redirect loop in middleware
Redirect loop in middleware
Make sure your login page is in
publicRoutes and not in protectedRoutes.Next Steps
React SDK
Client-side hooks reference
Node.js SDK
Backend token verification