Skip to content

Commit

Permalink
fix: update clerk oauth provider types
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Dec 9, 2023
1 parent ff13af6 commit 02d5606
Show file tree
Hide file tree
Showing 14 changed files with 1,096 additions and 947 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-rats-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@saas-ui/clerk': patch
---

Updated clerk provider types
4 changes: 2 additions & 2 deletions examples/clerk-auth/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TypeScript Next.js Saas UI example
# TypeScript Next.js Saas UI Clerk example

This is a really simple project that shows the usage of Next.js with TypeScript.
This is a basic example of how to use [Clerk](https://clerk.dev) to add authentication to a Next.js app using Saas UI

## Deploy your own

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
'use client'

import { Stack, Card, CardBody } from '@chakra-ui/react'
import { Auth, AvailableProviders, useAuth } from '@saas-ui/auth'
import { useRouter } from 'next/router'
import { useRouter } from 'next/navigation'
import React from 'react'

import { FaGithub } from 'react-icons/fa'
import { Logo } from '../components/Logo'
import { FaGoogle } from 'react-icons/fa'
import { Logo } from '../../../components/Logo'
import { useSnackbar } from '@saas-ui/react'

const providers: AvailableProviders = {
github: {
icon: FaGithub,
name: 'Github',
google: {
icon: FaGoogle,
name: 'Google',
},
}

Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/clerk-auth/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Provider from './provider'

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<body>
<Provider>{children}</Provider>
</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Box, Button } from '@chakra-ui/react'
'use client'

import { Box, Button, Center } from '@chakra-ui/react'
import { LoadingOverlay, LoadingSpinner } from '@saas-ui/react'
import { useAuth } from '@saas-ui/auth'
import NextLink from 'next/link'
Expand All @@ -14,19 +16,21 @@ const IndexPage = () => {
)
} else if (!user) {
return (
<Box>
<Center h="$100vh">
<NextLink href="/login" legacyBehavior>
<Button>Log in</Button>
<Button variant="primary" size="lg">
Log in
</Button>
</NextLink>
</Box>
</Center>
)
}

return (
<Box>
<Center h="$100vh">
Logged in as: {user.email}.{' '}
<Button onClick={() => logOut()}>Log out</Button>
</Box>
</Center>
)
}

Expand Down
19 changes: 19 additions & 0 deletions examples/clerk-auth/app/provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use client'

import { SaasProvider } from '@saas-ui/react'
import { ClerkAuthProvider } from '@saas-ui/clerk/src'
import { AuthProvider } from '@saas-ui/auth'

export default function Provider({ children }: { children: React.ReactNode }) {
return (
<ClerkAuthProvider
publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}
>
{({ authService }) => (
<SaasProvider>
<AuthProvider {...authService}>{children}</AuthProvider>
</SaasProvider>
)}
</ClerkAuthProvider>
)
}
Loading

0 comments on commit 02d5606

Please sign in to comment.