mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
updated adapters to automatically verify auth
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import { type MetaFunction, useLoaderData } from "@remix-run/react";
|
||||
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
|
||||
import { useAuth } from "bknd/client";
|
||||
|
||||
export const meta: MetaFunction = () => {
|
||||
return [{ title: "Remix & bknd" }, { name: "description", content: "Welcome to Remix & bknd!" }];
|
||||
};
|
||||
|
||||
export const loader = async (args: LoaderFunctionArgs) => {
|
||||
const api = args.context.api;
|
||||
await api.verifyAuth();
|
||||
export const loader = async ({ context: { api } }: LoaderFunctionArgs) => {
|
||||
const { data } = await api.data.readMany("todos");
|
||||
return { data, user: api.getUser() };
|
||||
};
|
||||
|
||||
export default function Index() {
|
||||
const { data, user } = useLoaderData<typeof loader>();
|
||||
const auth = useAuth();
|
||||
console.log("auth", auth);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user