chore(example): fix SvelteKit example (#1742)

* refactor: upgrade Svelte, Vite and related packages

* refactor: replace no longer supported `body.callbackURL` with `onSuccess`

* fix: add missing `svelte-kit sync` on `prepare`

* fix: add missing `import`s

* chore(svelte-kit-example): show message & redirect to index after sign up

* chore: add npm script to migrate database

* doc: add more commands to set up

* chore: explicitly disable verification email on sign up

The example does not work if you set `sendOnSignUp: true` without setting up the email server.

* refactor(svelte-kit-example): add type for hooks

* chore(svelte-kit-example): redirect to sign in page if users open dashboard without log in

* chore: diable some rules for svelte-kit-example due to Biome's limited Svelte support

* style: fix format

* chore: update pnpm-lock.yaml

* chore: fix lock file

---------

Co-authored-by: Bereket Engida <Bekacru@gmail.com>
This commit is contained in:
Jumpei Ogawa
2025-07-26 05:32:17 +09:00
committed by GitHub
parent f99305b29e
commit 40cefe99b1
73 changed files with 628 additions and 472 deletions

View File

@@ -27,6 +27,18 @@
}
}
},
"overrides": [
{
"include": ["examples/svelte-kit-example/**"],
"linter": {
"rules": {
"correctness": {
"noUnusedImports": "off"
}
}
}
}
],
"files": {
"ignore": [
"dist",

View File

@@ -19,3 +19,8 @@ Thumbs.db
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
# You cannot create root page under (protected)/ route
# because it is not protected by authwall.
./src/routes/(protected)/+page.*
./src/routes/(protected)/+server.*

View File

@@ -12,7 +12,11 @@ Email & Password . <u>Social Sign-in with Google</u> . Passkeys . Email Verifica
2. Move .env.example to .env and provide necessary variables
3. Run the following commands
```bash
cd /path/to/better-auth/ # Project root of this better-auth repo, not the root of this example
pnpm install
pnpm build
cd ./examples/svelte-kit-example/ # The root of this example project
pnpm migrate
pnpm dev
```
4. Open the browser and navigate to `http://localhost:3000`

View File

@@ -5,21 +5,24 @@
"scripts": {
"dev": "vite dev --port 3000",
"build": "vite build",
"migrate": "pnpx @better-auth/cli migrate",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"prepare": "svelte-kit sync"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.3.1",
"@better-auth/cli": "workspace:*",
"@sveltejs/adapter-auto": "^4.0.0",
"@sveltejs/kit": "^2.9.0",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tailwindcss/typography": "^0.5.15",
"autoprefixer": "^10.4.20",
"svelte": "^4.2.19",
"svelte": "^5.22.5",
"svelte-check": "^4.1.1",
"tailwindcss": "^3.4.16",
"typescript": "^5.7.2",
"vite": "^5.4.19"
"vite": "^6.3.0"
},
"type": "module",
"dependencies": {
@@ -34,7 +37,7 @@
"formsnap": "^1.0.1",
"mode-watcher": "^0.4.1",
"paneforge": "^0.0.6",
"svelte-radix": "^1.1.1",
"svelte-radix": "^2.0.1",
"svelte-sonner": "^0.3.28",
"sveltekit-superforms": "^2.21.1",
"tailwind-merge": "^2.5.5",

View File

@@ -2,8 +2,11 @@
// for information about these interfaces
declare global {
namespace App {
interface Locals {
session?: Session;
user?: User;
}
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}

View File

@@ -1,6 +1,22 @@
import { auth } from "$lib/auth";
import { redirect, type Handle } from "@sveltejs/kit";
import { svelteKitHandler } from "better-auth/svelte-kit";
export async function handle({ event, resolve }) {
return svelteKitHandler({ event, resolve, auth });
}
export const handle: Handle = async ({ event, resolve }) => {
if (event.route.id?.startsWith("/(protected)/")) {
const session = await auth.api.getSession({
headers: event.request.headers,
});
if (session) {
event.locals.session = session?.session;
event.locals.user = session?.user;
return svelteKitHandler({ event, resolve, auth });
} else {
redirect(307, "/sign-in");
}
} else {
return svelteKitHandler({ event, resolve, auth });
}
};

View File

@@ -16,4 +16,10 @@ export const auth = betterAuth({
console.log("Reset password url:", url);
},
},
emailVerification: {
sendOnSignUp: false, // TODO enable this option to send email to the user on sign up
// sendVerificationEmail: async ({ user, url, token }, request) => {
// // TODO add function(s) to send verification email.
// },
},
});

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { AlertDialog as AlertDialogPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AlertDialogPrimitive.CancelProps;
type $$Events = AlertDialogPrimitive.CancelEvents;

View File

@@ -1,6 +1,8 @@
<script lang="ts">
import { AlertDialog as AlertDialogPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
import AlertDialogOverlay from "./alert-dialog-overlay.svelte";
import AlertDialogPortal from "./alert-dialog-portal.svelte";
type $$Props = AlertDialogPrimitive.ContentProps;
@@ -10,8 +12,8 @@ export let transitionConfig: $$Props["transitionConfig"] = undefined;
export { className as class };
</script>
<AlertDialog.Portal>
<AlertDialog.Overlay />
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
{transition}
{transitionConfig}
@@ -23,4 +25,4 @@ export { className as class };
>
<slot />
</AlertDialogPrimitive.Content>
</AlertDialog.Portal>
</AlertDialogPortal>

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AvatarPrimitive.FallbackProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AvatarPrimitive.ImageProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AvatarPrimitive.Props;

View File

@@ -1,5 +1,7 @@
<script lang="ts">
import { type Events, type Props } from "./index.js";
import { Button as ButtonPrimitive } from "bits-ui";
import { buttonVariants, type Events, type Props } from "./index.js";
import { cn } from "$lib/utils.js";
type $$Props = Props;
type $$Events = Events;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Calendar as CalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = CalendarPrimitive.NextButtonProps;
type $$Events = CalendarPrimitive.NextButtonEvents;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Calendar as CalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = CalendarPrimitive.PrevButtonProps;
type $$Events = CalendarPrimitive.PrevButtonEvents;

View File

@@ -1,5 +1,18 @@
<script lang="ts">
import { Calendar as CalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import CalendarCell from "./calendar-cell.svelte";
import CalendarDay from "./calendar-day.svelte";
import CalendarGridBody from "./calendar-grid-body.svelte";
import CalendarGridHead from "./calendar-grid-head.svelte";
import CalendarGridRow from "./calendar-grid-row.svelte";
import CalendarGrid from "./calendar-grid.svelte";
import CalendarHeadCell from "./calendar-head-cell.svelte";
import CalendarHeader from "./calendar-header.svelte";
import CalendarHeading from "./calendar-heading.svelte";
import CalendarMonths from "./calendar-months.svelte";
import CalendarNextButton from "./calendar-next-button.svelte";
import CalendarPrevButton from "./calendar-prev-button.svelte";
type $$Props = CalendarPrimitive.Props;
type $$Events = CalendarPrimitive.Events;
@@ -22,35 +35,35 @@ export { className as class };
let:months
let:weekdays
>
<Calendar.Header>
<Calendar.PrevButton />
<Calendar.Heading />
<Calendar.NextButton />
</Calendar.Header>
<Calendar.Months>
<CalendarHeader>
<CalendarPrevButton />
<CalendarHeading />
<CalendarNextButton />
</CalendarHeader>
<CalendarMonths>
{#each months as month}
<Calendar.Grid>
<Calendar.GridHead>
<Calendar.GridRow class="flex">
<CalendarGrid>
<CalendarGridHead>
<CalendarGridRow class="flex">
{#each weekdays as weekday}
<Calendar.HeadCell>
<CalendarHeadCell>
{weekday.slice(0, 2)}
</Calendar.HeadCell>
</CalendarHeadCell>
{/each}
</Calendar.GridRow>
</Calendar.GridHead>
<Calendar.GridBody>
</CalendarGridRow>
</CalendarGridHead>
<CalendarGridBody>
{#each month.weeks as weekDates}
<Calendar.GridRow class="mt-2 w-full">
<CalendarGridRow class="mt-2 w-full">
{#each weekDates as date}
<Calendar.Cell {date}>
<Calendar.Day {date} month={month.value} />
</Calendar.Cell>
<CalendarCell {date}>
<CalendarDay {date} month={month.value} />
</CalendarCell>
{/each}
</Calendar.GridRow>
</CalendarGridRow>
{/each}
</Calendar.GridBody>
</Calendar.Grid>
</CalendarGridBody>
</CalendarGrid>
{/each}
</Calendar.Months>
</CalendarMonths>
</CalendarPrimitive.Root>

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLParagraphElement>;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
import type { HeadingLevel } from "./index.js";

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ContextMenu as ContextMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = ContextMenuPrimitive.CheckboxItemProps;
type $$Events = ContextMenuPrimitive.CheckboxItemEvents;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { ContextMenu as ContextMenuPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = ContextMenuPrimitive.ContentProps;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { ContextMenu as ContextMenuPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = ContextMenuPrimitive.SubContentProps;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { Dialog as DialogPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = DialogPrimitive.ContentProps;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = DropdownMenuPrimitive.ContentProps;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = DropdownMenuPrimitive.SubContentProps;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { LinkPreview as HoverCardPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = HoverCardPrimitive.ContentProps;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLInputAttributes } from "svelte/elements";
import type { InputEvents } from "./index.js";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Label as LabelPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = LabelPrimitive.Props;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.CheckboxItemProps;
let className: $$Props["class"] = undefined;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = MenubarPrimitive.ContentProps;
let className: $$Props["class"] = undefined;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.ItemProps & {
inset?: boolean;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.LabelProps & {
inset?: boolean;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.RadioItemProps;
type $$Events = MenubarPrimitive.RadioItemEvents;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.SeparatorProps;
let className: $$Props["class"] = undefined;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLSpanElement>;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = MenubarPrimitive.SubContentProps;
let className: $$Props["class"] = undefined;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.SubTriggerProps & {
inset?: boolean;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.TriggerProps;
type $$Events = MenubarPrimitive.TriggerEvents;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Menubar as MenubarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = MenubarPrimitive.Props;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLUListElement>;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLSpanElement>;

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLLIElement>;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Pagination as PaginationPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { type Props } from "$lib/components/ui/button/index.js";
type $$Props = PaginationPrimitive.PageProps &

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Pagination as PaginationPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = PaginationPrimitive.Props;
type $$Events = PaginationPrimitive.Events;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { Popover as PopoverPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = PopoverPrimitive.ContentProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { Progress as ProgressPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = ProgressPrimitive.Props;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RadioGroup as RadioGroupPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RadioGroupPrimitive.ItemProps & {
value: string;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RadioGroup as RadioGroupPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RadioGroupPrimitive.Props;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.CellProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.DayProps;
type $$Events = RangeCalendarPrimitive.DayEvents;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.GridBodyProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.GridHeadProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.GridRowProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.GridProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.HeadCellProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.HeaderProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.HeadingProps;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.NextButtonProps;
type $$Events = RangeCalendarPrimitive.NextButtonEvents;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.PrevButtonProps;
type $$Events = RangeCalendarPrimitive.PrevButtonEvents;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = RangeCalendarPrimitive.Props;
type $$Events = RangeCalendarPrimitive.Events;

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { Select as SelectPrimitive } from "bits-ui";
import { scale } from "svelte/transition";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = SelectPrimitive.ContentProps;

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { Tooltip as TooltipPrimitive } from "bits-ui";
import { flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = TooltipPrimitive.ContentProps;

View File

@@ -1,7 +1,15 @@
<script>
import { goto } from "$app/navigation";
import { client } from "$lib/auth-client";
import * as Avatar from "$lib/components/ui/avatar";
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card";
const session = client.useSession();
if (!session) {
goto("/sign-in");
}
</script>
<Card.Root class="w-[350px]">
@@ -33,9 +41,7 @@ const session = client.useSession();
on:click={() => {
client.signOut({
fetchOptions: {
body: {
callbackURL: "/",
},
onSuccess: () => goto("/auth"),
},
});
}}>Sign Out</Button

View File

@@ -1,5 +1,7 @@
<script>
import { client } from "$lib/auth-client";
import Button from "$lib/components/ui/button/button.svelte";
const features = [
"social sign-in",
"email and password",

View File

@@ -1,5 +1,10 @@
<script lang="ts">
import { writable } from "svelte/store";
import { client } from "$lib/auth-client.js";
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card";
import { Input } from "$lib/components/ui/input";
import { Label } from "$lib/components/ui/label";
const email = writable("");
</script>

View File

@@ -1,5 +1,10 @@
<script>
import { writable } from "svelte/store";
import { client } from "$lib/auth-client.js";
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card";
import { Input } from "$lib/components/ui/input";
import { Label } from "$lib/components/ui/label";
const confirmPassword = writable("");
const password = writable("");

View File

@@ -1,6 +1,10 @@
<script lang="ts">
import { signIn } from "$lib/auth-client";
import { writable } from "svelte/store";
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card";
import { Input } from "$lib/components/ui/input";
import { Label } from "$lib/components/ui/label";
const email = writable("");
const password = writable("");

View File

@@ -1,6 +1,11 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { signUp } from "$lib/auth-client";
import { writable } from "svelte/store";
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card";
import { Input } from "$lib/components/ui/input";
import { Label } from "$lib/components/ui/label";
// Create writable stores for form fields
const firstName = writable("");
@@ -22,6 +27,10 @@ const handleSignUp = async () => {
name: `${user.firstName} ${user.lastName}`,
callbackURL: "/",
fetchOptions: {
onSuccess() {
alert("Your account has been created.");
goto("/dashboard");
},
onError(context) {
alert(context.error.message);
},

856
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff