Client hooks always return 404

Hey guys any idea why using the organization hooks return a 404? it works fine server side
const organizations = useListOrganizations();
const session = useSession();
const currOrg = useActiveOrganization();
const organizations = useListOrganizations();
const session = useSession();
const currOrg = useActiveOrganization();
GET /api/auth/use-active-organization?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite 404 in 1447ms
GET /api/auth/use-list-organizations?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite 404 in 724ms
GET /api/auth/use-session?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite 404 in 695ms
GET /api/auth/use-active-organization?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite 404 in 1447ms
GET /api/auth/use-list-organizations?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite 404 in 724ms
GET /api/auth/use-session?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite 404 in 695ms
5 Replies
Tee
TeeOP3mo ago
im using nextjs 15 btw @admin can anyone help please
bekacru
bekacru3mo ago
could you share the file where you initated the auth client
Tee
TeeOP3mo ago
import { toast } from "@repo/ui/components/sonner";
import { createAuthClient } from "better-auth/client";
import { organizationClient } from "better-auth/client/plugins";

export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
plugins: [organizationClient()],
fetchOptions: {
onError(e) {
if (e.error.status === 429) {
toast.error("Too many requests. Please try again later.");
}
},
},
});


export const {
signUp,
signIn,
signOut,
useSession,
organization,
useListOrganizations,
useActiveOrganization,
} = authClient;
import { toast } from "@repo/ui/components/sonner";
import { createAuthClient } from "better-auth/client";
import { organizationClient } from "better-auth/client/plugins";

export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
plugins: [organizationClient()],
fetchOptions: {
onError(e) {
if (e.error.status === 429) {
toast.error("Too many requests. Please try again later.");
}
},
},
});


export const {
signUp,
signIn,
signOut,
useSession,
organization,
useListOrganizations,
useActiveOrganization,
} = authClient;
im following the nextjs example from the repo this is in /lib/auth/client
bekacru
bekacru3mo ago
you're importing createAuthClient from "/client". You should import it from "better-auth/react"
Tee
TeeOP3mo ago
GET /api/auth/get-session 200 in 306ms
GET /api/auth/organization/get-full-organization 401 in 344ms
GET /api/auth/get-session?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite%2Ftags 200 in 773ms
GET /api/auth/organization/list?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite%2Ftags 200 in 1751ms
GET /api/auth/organization/get-full-organization?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite%2Ftags 200
GET /api/auth/get-session 200 in 306ms
GET /api/auth/organization/get-full-organization 401 in 344ms
GET /api/auth/get-session?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite%2Ftags 200 in 773ms
GET /api/auth/organization/list?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite%2Ftags 200 in 1751ms
GET /api/auth/organization/get-full-organization?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fgraphite%2Ftags 200
it works!! thank you so much

Did you find this page helpful?