an app to share curated trails
sidetrail.app
atproto
nextjs
react
rsc
1"use client";
2
3import { createContext, useContext, ReactNode } from "react";
4
5type AuthContextType = {
6 did: string | null;
7};
8
9const AuthContext = createContext<AuthContextType | null>(null);
10
11export function AuthProvider({ children, did }: { children: ReactNode; did: string | null }) {
12 return <AuthContext.Provider value={{ did }}>{children}</AuthContext.Provider>;
13}
14
15export function useAuthContext() {
16 const context = useContext(AuthContext);
17 if (!context) {
18 throw new Error("useLoginModal must be used within a AuthProvider");
19 }
20 return context;
21}