@secureshare/nextjs
v1.0.1
Published
SecureShare authentication SDK for Next.js applications
Maintainers
Readme
@secureshare/nextjs
Official SecureShare SDK for Next.js applications. Add complete authentication to your app in minutes.
Installation
```bash npm install @secureshare/nextjs ```
Quick Start
1. Set up environment variables
Add these to your .env.local:
```env NEXT_PUBLIC_SECURESHARE_WORKSPACE_ID=your_workspace_id NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key ```
2. Wrap your app with SecureShareProvider
```tsx // app/layout.tsx import { SecureShareProvider } from '@secureshare/nextjs'
export default function RootLayout({ children }) { return ( {children} ) } ```
3. Add authentication pages
```tsx // app/sign-in/page.tsx import { SignIn } from '@secureshare/nextjs'
export default function SignInPage() { return } ```
```tsx // app/sign-up/page.tsx import { SignUp } from '@secureshare/nextjs'
export default function SignUpPage() { return } ```
4. Protect your routes
```tsx // app/dashboard/page.tsx import { protect, currentUser } from '@secureshare/nextjs/server'
export default async function DashboardPage() { await protect() // Redirects to /sign-in if not authenticated const user = await currentUser()
return Welcome, {user?.firstName}! } ```
5. Use authentication in client components
```tsx 'use client'
import { useUser, UserButton } from '@secureshare/nextjs'
export function Header() { const { user, isSignedIn } = useUser()
return ( {isSignedIn ? ( ) : ( Sign In )} ) } ```
API Reference
Client Components
<SecureShareProvider>- Wrap your app to provide authentication context<SignIn>- Pre-built sign in form<SignUp>- Pre-built sign up form<UserButton>- User profile dropdown with sign out
Client Hooks
useUser()- Get current user and authentication stateuseAuth()- Sign in, sign up, and sign out methodsuseOrganization()- Get user's organization
Server Functions
auth()- Get authentication state on the servercurrentUser()- Get full user object on the serverprotect()- Protect routes (redirects if not authenticated)createSecureShareClient()- Create Supabase client for server operations
License
MIT
