-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 425a376
Showing
34 changed files
with
716 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please visit https://dashboard.clerk.com to find your API Keys | ||
CLERK_PUBLISHABLE_KEY=pk_test_xxx | ||
CLERK_SECRET_KEY=sk_test_xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": ["react-app"], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["react-hooks"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
|
||
.DS_Store | ||
.cache | ||
.env | ||
.vercel | ||
.output | ||
.vinxi | ||
|
||
/build/ | ||
/api/ | ||
/server/build | ||
/public/build | ||
.vinxi | ||
# Sentry Config File | ||
.env.sentry-build-plugin | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**/api | ||
**/build | ||
**/public | ||
pnpm-lock.yaml | ||
routeTree.gen.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<p align="center"> | ||
<a href="https://clerk.com?utm_source=DevRel&utm_medium=docs&utm_campaign=templates&utm_content=08-05-2023&utm_term=clerk-tanstack-start-quickstart" target="_blank" rel="noopener noreferrer"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset="./public/light-logo.png"> | ||
<img alt="Clerk Logo for light background" src="./public/dark-logo.png" height="64"> | ||
</picture> | ||
</a> | ||
<br /> | ||
</p> | ||
<div align="center"> | ||
<h1> | ||
Clerk and TanStack Start Quickstart | ||
</h1> | ||
<a href="https://www.npmjs.com/package/@clerk/clerk-react"> | ||
<img alt="Downloads" src="https://img.shields.io/npm/dm/@clerk/clerk-react" /> | ||
</a> | ||
<a href="https://discord.com/invite/b5rXHjAg7A"> | ||
<img alt="Discord" src="https://img.shields.io/discord/856971667393609759?color=7389D8&label&logo=discord&logoColor=ffffff" /> | ||
</a> | ||
<a href="https://twitter.com/clerkdev"> | ||
<img alt="Twitter" src="https://img.shields.io/twitter/url.svg?label=%40clerkdev&style=social&url=https%3A%2F%2Ftwitter.com%2Fclerkdev" /> | ||
</a> | ||
<br /> | ||
<br /> | ||
<img alt="Clerk Hero Image" src="./public/hero.png"> | ||
</div> | ||
|
||
## Introduction | ||
|
||
Clerk is a developer-first authentication and user management solution. It provides pre-built components and hooks for sign-in, sign-up, user profile, and organization management. Clerk is designed to be easy to use and customize, and can be integrated into any TanStack Start application. | ||
|
||
After following the [Clerk TanStack Start quickstart](https://clerk.com/docs/quickstarts/tanstack-start?utm_source=DevRel&utm_medium=docs&utm_campaign=templates&utm_content=08-05-2023&utm_term=clerk-tanstack-start-quickstart), you will have learned how to: | ||
|
||
- Create a new TanStack Start application | ||
- Install `@clerk/tanstack-start` | ||
- Set up your environment keys | ||
- Import the Clerk Publishable Key | ||
- Wrap your Root Component app in `<ClerkProvider />` | ||
- Use Clerk components to protect your content | ||
- Embed the `<SignInButton />` and `<SignOutButton />` | ||
- Deploy your application | ||
|
||
## Deploy | ||
|
||
Easily deploy the template to Vercel with the button below. You will need to set the required environment variables in the Vercel dashboard. | ||
|
||
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fclerk%2Fclerk-tanstack-start-quickstart&env=CLERK_PUBLISHABLE_KEY,CLERK_SECRET_KEY&envDescription=Clerk%20API%20keys&envLink=https%3A%2F%2Fclerk.com%2Fdocs%2Fquickstart%2Ftanstack-start&redirect-url=https%3A%2F%2Fclerk.com%2Fdocs%2Fquickstart%2Ftanstack-start) | ||
|
||
## Running the template | ||
|
||
```bash | ||
git clone https://github.com/clerk/clerk-tanstack-start-quickstart | ||
``` | ||
|
||
To run the example locally, you need to: | ||
|
||
1. Sign up for a Clerk account at [https://clerk.com](https://www.clerk.com?utm_source=DevRel&utm_medium=docs&utm_campaign=templates&utm_content=08-05-2023&utm_term=clerk-tanstack-start-quickstart). | ||
|
||
2. Go to the [Clerk dashboard](https://dashboard.clerk.com) and create an application. | ||
|
||
3. Set the required Clerk environment variables as shown in [the example `env` file](./.env.example). | ||
|
||
4. `npm install` the required dependencies. | ||
|
||
5. `npm run dev` to launch the development server. | ||
|
||
## Learn more | ||
|
||
To learn more about Clerk and TanStack Start, check out the following resources: | ||
|
||
- [Quickstart: Get started with TanStack Start and Clerk](https://clerk.com/docs/quickstarts/tanstack-start?utm_source=DevRel&utm_medium=docs&utm_campaign=templates&utm_content=08-05-2023&utm_term=clerk-tanstack-start-quickstart) | ||
- [Clerk Documentation](https://clerk.com/docs?utm_source=DevRel&utm_medium=docs&utm_campaign=templates&utm_content=08-05-2023&utm_term=clerk-tanstack-start-quickstart) | ||
|
||
## Found an issue or want to leave feedback | ||
|
||
Feel free to create a support thread on our [Discord](https://clerk.com/discord). Our support team will be happy to assist you in the `#support` channel. | ||
|
||
## Connect with us | ||
|
||
You can discuss ideas, ask questions, and meet others from the community in our [Discord](https://discord.com/invite/b5rXHjAg7A). | ||
|
||
If you prefer, you can also find support through our [Twitter](https://twitter.com/ClerkDev), or you can [email](mailto:[email protected]) us! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from '@tanstack/start/config' | ||
import tsConfigPaths from 'vite-tsconfig-paths' | ||
|
||
export default defineConfig({ | ||
vite: { | ||
plugins: () => [ | ||
tsConfigPaths({ | ||
projects: ['./tsconfig.json'], | ||
}), | ||
], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { hydrateRoot } from 'react-dom/client' | ||
import { StartClient } from '@tanstack/start' | ||
import { createRouter } from './router' | ||
|
||
const router = createRouter() | ||
|
||
hydrateRoot(document.getElementById('root')!, <StartClient router={router} />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
ErrorComponent, | ||
ErrorComponentProps, | ||
Link, | ||
rootRouteId, | ||
useMatch, | ||
useRouter, | ||
} from '@tanstack/react-router' | ||
|
||
export function DefaultCatchBoundary({ error }: ErrorComponentProps) { | ||
const router = useRouter() | ||
const isRoot = useMatch({ | ||
strict: false, | ||
select: (state) => state.id === rootRouteId, | ||
}) | ||
|
||
console.error(error) | ||
|
||
return ( | ||
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6"> | ||
<ErrorComponent error={error} /> | ||
<div className="flex gap-2 items-center flex-wrap"> | ||
<button | ||
onClick={() => { | ||
router.invalidate() | ||
}} | ||
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`} | ||
> | ||
Try Again | ||
</button> | ||
{isRoot ? ( | ||
<Link | ||
to="/" | ||
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`} | ||
> | ||
Home | ||
</Link> | ||
) : ( | ||
<Link | ||
to="/" | ||
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`} | ||
onClick={(e) => { | ||
e.preventDefault() | ||
window.history.back() | ||
}} | ||
> | ||
Go Back | ||
</Link> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Link } from '@tanstack/react-router' | ||
|
||
export function NotFound({ children }: { children?: any }) { | ||
return ( | ||
<div className="space-y-2 p-2"> | ||
<div className="text-gray-600 dark:text-gray-400"> | ||
{children || <p>The page you are looking for does not exist.</p>} | ||
</div> | ||
<p className="flex items-center gap-2 flex-wrap"> | ||
<button | ||
onClick={() => window.history.back()} | ||
className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm" | ||
> | ||
Go back | ||
</button> | ||
<Link | ||
to="/" | ||
className="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm" | ||
> | ||
Start Over | ||
</Link> | ||
</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* prettier-ignore-start */ | ||
|
||
/* eslint-disable */ | ||
|
||
// @ts-nocheck | ||
|
||
// noinspection JSUnusedGlobalSymbols | ||
|
||
// This file is auto-generated by TanStack Router | ||
|
||
// Import Routes | ||
|
||
import { Route as rootRoute } from './routes/__root' | ||
import { Route as LayoutImport } from './routes/_layout' | ||
import { Route as IndexImport } from './routes/index' | ||
import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' | ||
import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' | ||
import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' | ||
|
||
// Create/Update Routes | ||
|
||
const LayoutRoute = LayoutImport.update({ | ||
id: '/_layout', | ||
getParentRoute: () => rootRoute, | ||
} as any) | ||
|
||
const IndexRoute = IndexImport.update({ | ||
path: '/', | ||
getParentRoute: () => rootRoute, | ||
} as any) | ||
|
||
const LayoutLayout2Route = LayoutLayout2Import.update({ | ||
id: '/_layout-2', | ||
getParentRoute: () => LayoutRoute, | ||
} as any) | ||
|
||
const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ | ||
path: '/layout-b', | ||
getParentRoute: () => LayoutLayout2Route, | ||
} as any) | ||
|
||
const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ | ||
path: '/layout-a', | ||
getParentRoute: () => LayoutLayout2Route, | ||
} as any) | ||
|
||
// Populate the FileRoutesByPath interface | ||
|
||
declare module '@tanstack/react-router' { | ||
interface FileRoutesByPath { | ||
'/': { | ||
id: '/' | ||
path: '/' | ||
fullPath: '/' | ||
preLoaderRoute: typeof IndexImport | ||
parentRoute: typeof rootRoute | ||
} | ||
'/_layout': { | ||
id: '/_layout' | ||
path: '' | ||
fullPath: '' | ||
preLoaderRoute: typeof LayoutImport | ||
parentRoute: typeof rootRoute | ||
} | ||
'/_layout/_layout-2': { | ||
id: '/_layout/_layout-2' | ||
path: '' | ||
fullPath: '' | ||
preLoaderRoute: typeof LayoutLayout2Import | ||
parentRoute: typeof LayoutImport | ||
} | ||
'/_layout/_layout-2/layout-a': { | ||
id: '/_layout/_layout-2/layout-a' | ||
path: '/layout-a' | ||
fullPath: '/layout-a' | ||
preLoaderRoute: typeof LayoutLayout2LayoutAImport | ||
parentRoute: typeof LayoutLayout2Import | ||
} | ||
'/_layout/_layout-2/layout-b': { | ||
id: '/_layout/_layout-2/layout-b' | ||
path: '/layout-b' | ||
fullPath: '/layout-b' | ||
preLoaderRoute: typeof LayoutLayout2LayoutBImport | ||
parentRoute: typeof LayoutLayout2Import | ||
} | ||
} | ||
} | ||
|
||
// Create and export the route tree | ||
|
||
export const routeTree = rootRoute.addChildren({ | ||
IndexRoute, | ||
LayoutRoute: LayoutRoute.addChildren({ | ||
LayoutLayout2Route: LayoutLayout2Route.addChildren({ | ||
LayoutLayout2LayoutARoute, | ||
LayoutLayout2LayoutBRoute, | ||
}), | ||
}), | ||
}) | ||
|
||
/* prettier-ignore-end */ | ||
|
||
/* ROUTE_MANIFEST_START | ||
{ | ||
"routes": { | ||
"__root__": { | ||
"filePath": "__root.tsx", | ||
"children": [ | ||
"/", | ||
"/_layout" | ||
] | ||
}, | ||
"/": { | ||
"filePath": "index.tsx" | ||
}, | ||
"/_layout": { | ||
"filePath": "_layout.tsx", | ||
"children": [ | ||
"/_layout/_layout-2" | ||
] | ||
}, | ||
"/_layout/_layout-2": { | ||
"filePath": "_layout/_layout-2.tsx", | ||
"parent": "/_layout", | ||
"children": [ | ||
"/_layout/_layout-2/layout-a", | ||
"/_layout/_layout-2/layout-b" | ||
] | ||
}, | ||
"/_layout/_layout-2/layout-a": { | ||
"filePath": "_layout/_layout-2/layout-a.tsx", | ||
"parent": "/_layout/_layout-2" | ||
}, | ||
"/_layout/_layout-2/layout-b": { | ||
"filePath": "_layout/_layout-2/layout-b.tsx", | ||
"parent": "/_layout/_layout-2" | ||
} | ||
} | ||
} | ||
ROUTE_MANIFEST_END */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createRouter as createTanStackRouter } from '@tanstack/react-router' | ||
import { routeTree } from './routeTree.gen' | ||
import { DefaultCatchBoundary } from './components/DefaultCatchBoundary' | ||
import { NotFound } from './components/NotFound' | ||
|
||
export function createRouter() { | ||
const router = createTanStackRouter({ | ||
routeTree, | ||
defaultPreload: 'intent', | ||
defaultErrorComponent: DefaultCatchBoundary, | ||
defaultNotFoundComponent: () => <NotFound />, | ||
}) | ||
|
||
return router | ||
} | ||
|
||
declare module '@tanstack/react-router' { | ||
interface Register { | ||
router: ReturnType<typeof createRouter> | ||
} | ||
} |
Oops, something went wrong.