Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/vite-better-auth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sqlite
33 changes: 33 additions & 0 deletions examples/vite-better-auth/app/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import "./styles.css";

import { Route, Switch } from "wouter";
import { LoadingSkeleton } from "./components/loading";

Check failure on line 5 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './components/loading.jsx'?

Check failure on line 5 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './components/loading.jsx'?

const Homepage = React.lazy(() => import("./routes/index"));

Check failure on line 7 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './routes/index.jsx'?

Check failure on line 7 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './routes/index.jsx'?
const AuthSignIn = React.lazy(() => import("./routes/auth/sign-in"));

Check failure on line 8 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './routes/auth/sign-in.jsx'?

Check failure on line 8 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './routes/auth/sign-in.jsx'?
const AuthSignUp = React.lazy(() => import("./routes/auth/sign-up"));

Check failure on line 9 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './routes/auth/sign-up.jsx'?

Check failure on line 9 in examples/vite-better-auth/app/app.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './routes/auth/sign-up.jsx'?

export const App = () => {
return (
<>
<nav className="flex justify-between items-center p-4 border-b mb-4">
<a href="/">Home</a>
<div>
<a href="/auth/sign-in" className="mr-4">
Sign In
</a>
</div>
</nav>
<React.Suspense fallback={<LoadingSkeleton />}>
<div className="flex justify-center items-center min-h-[60vh] w-full">
<Switch>
<Route path="/" component={Homepage} />
<Route path="/auth/sign-in" component={AuthSignIn} />
<Route path="/auth/sign-up" component={AuthSignUp} />
</Switch>
</div>
</React.Suspense>
</>
);
};
12 changes: 12 additions & 0 deletions examples/vite-better-auth/app/components/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const LoadingSkeleton = () => (
<div className="flex justify-center items-center min-h-[60vh] w-full">
<div className="w-full max-w-md space-y-4 p-6">
<div className="h-8 bg-muted rounded animate-pulse w-3/4 mx-auto" />
<div className="space-y-3">
<div className="h-10 bg-muted rounded animate-pulse" />
<div className="h-10 bg-muted rounded animate-pulse" />
<div className="h-10 bg-muted rounded animate-pulse w-1/2" />
</div>
</div>
</div>
);
18 changes: 18 additions & 0 deletions examples/vite-better-auth/app/components/nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useSession } from "../utils/auth";

Check failure on line 1 in examples/vite-better-auth/app/components/nav.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../utils/auth.js'?

Check failure on line 1 in examples/vite-better-auth/app/components/nav.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../utils/auth.js'?

export default () => {
const session = useSession();

Check failure on line 4 in examples/vite-better-auth/app/components/nav.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

'session' is declared but its value is never read.

Check failure on line 4 in examples/vite-better-auth/app/components/nav.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

'session' is declared but its value is never read.

return (
<>
<nav className="flex justify-between items-center p-4 border-b mb-4">
<a href="/">Home</a>
<div>
<a href="/auth/sign-in" className="mr-4">
Sign In
</a>
</div>
</nav>
</>
);
};
62 changes: 62 additions & 0 deletions examples/vite-better-auth/app/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/app/utils/tailwindcss";

Check failure on line 5 in examples/vite-better-auth/app/components/ui/button.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

Check failure on line 5 in examples/vite-better-auth/app/components/ui/button.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost:
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2 has-[>svg]:px-3",
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
icon: "size-9",
"icon-sm": "size-8",
"icon-lg": "size-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
);

function Button({
className,
variant = "default",
size = "default",
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean;
}) {
const Comp = asChild ? Slot : "button";

return (
<Comp
data-slot="button"
data-variant={variant}
data-size={size}
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
);
}

export { Button, buttonVariants };
92 changes: 92 additions & 0 deletions examples/vite-better-auth/app/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as React from "react";

import { cn } from "@/app/utils/tailwindcss";

Check failure on line 3 in examples/vite-better-auth/app/components/ui/card.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

Check failure on line 3 in examples/vite-better-auth/app/components/ui/card.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
className
)}
{...props}
/>
);
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className
)}
{...props}
/>
);
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("leading-none font-semibold", className)}
{...props}
/>
);
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
}

function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
)}
{...props}
/>
);
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
className={cn("px-6", className)}
{...props}
/>
);
}

function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
);
}

export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardAction,
CardDescription,
CardContent,
};
30 changes: 30 additions & 0 deletions examples/vite-better-auth/app/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { CheckIcon } from "lucide-react";

import { cn } from "@/app/utils/tailwindcss";

Check failure on line 5 in examples/vite-better-auth/app/components/ui/checkbox.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

Check failure on line 5 in examples/vite-better-auth/app/components/ui/checkbox.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

function Checkbox({
className,
...props
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
return (
<CheckboxPrimitive.Root
data-slot="checkbox"
className={cn(
"peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
data-slot="checkbox-indicator"
className="grid place-content-center text-current transition-none"
>
<CheckIcon className="size-3.5" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
);
}

export { Checkbox };
21 changes: 21 additions & 0 deletions examples/vite-better-auth/app/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from "react";

import { cn } from "@/app/utils/tailwindcss";

Check failure on line 3 in examples/vite-better-auth/app/components/ui/input.tsx

View workflow job for this annotation

GitHub Actions / tests-checks (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

Check failure on line 3 in examples/vite-better-auth/app/components/ui/input.tsx

View workflow job for this annotation

GitHub Actions / tests-rollup (ubuntu-latest)

Cannot find module '@/app/utils/tailwindcss' or its corresponding type declarations.

function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<input
type={type}
data-slot="input"
className={cn(
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
className
)}
{...props}
/>
);
}

export { Input };
22 changes: 22 additions & 0 deletions examples/vite-better-auth/app/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";

import { cn } from "@/app/utils/tailwindcss";

function Label({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
data-slot="label"
className={cn(
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
className
)}
{...props}
/>
);
}

export { Label };
64 changes: 64 additions & 0 deletions examples/vite-better-auth/app/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as React from "react";
import * as TabsPrimitive from "@radix-ui/react-tabs";

import { cn } from "@/app/utils/tailwindcss";

function Tabs({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
return (
<TabsPrimitive.Root
data-slot="tabs"
className={cn("flex flex-col gap-2", className)}
{...props}
/>
);
}

function TabsList({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.List>) {
return (
<TabsPrimitive.List
data-slot="tabs-list"
className={cn(
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
className
)}
{...props}
/>
);
}

function TabsTrigger({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
return (
<TabsPrimitive.Trigger
data-slot="tabs-trigger"
className={cn(
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
/>
);
}

function TabsContent({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
return (
<TabsPrimitive.Content
data-slot="tabs-content"
className={cn("flex-1 outline-none", className)}
{...props}
/>
);
}

export { Tabs, TabsList, TabsTrigger, TabsContent };
6 changes: 6 additions & 0 deletions examples/vite-better-auth/app/entry/client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "@vitejs/plugin-react/preamble";
import { hydrateRoot } from "react-dom/client";

import { App } from "@/app/app.tsx";

hydrateRoot(document.querySelector("#app")!, <App />);
Loading
Loading