Getting a 404 on useSession and unable to use Svelte Store

Hi there, When making a request to: api/auth/use-session I am recieving a 404. This is made to a Honojs backend. Then on the Svelte side when I try use the store or value from the useSession method it is saying it is not a store. When making a request to get-session this resolves fine and a user is returned. Code is something like below:
// Current calls
const useSessionData = authClient.useSession(); // 404
const getSessionData = authClient.getSession(); // 200

// Example usage
<script lang="ts">
import {authClient} from "$src/auth.client.ts";

const session = authClient.useSession();
</script>

<main>
<p>
{$session.data?.user.email}
</p>
</main>
// Current calls
const useSessionData = authClient.useSession(); // 404
const getSessionData = authClient.getSession(); // 200

// Example usage
<script lang="ts">
import {authClient} from "$src/auth.client.ts";

const session = authClient.useSession();
</script>

<main>
<p>
{$session.data?.user.email}
</p>
</main>
`session` is not a store with a `subscribe` method

https://svelte.dev/e/store_invalid_shape
at Module.store_invalid_shape (C:\Users\luker\dev\utickets\node_modules\svelte\src\internal\shared\errors.js:43:17)
`session` is not a store with a `subscribe` method

https://svelte.dev/e/store_invalid_shape
at Module.store_invalid_shape (C:\Users\luker\dev\utickets\node_modules\svelte\src\internal\shared\errors.js:43:17)
No description
2 Replies
vamshinenu
vamshinenu5d ago
Is there a reason you would not want to use getsession() I’m hoping session data email wouldn’t change? And is this how it should be done, Because in my projects, I don’t use the auth at all, I just have the check in the page, layout server files, @CodingWithLuke
CodingWithLuke
CodingWithLukeOP5d ago
Well use-session is just a wrapped version of get session that is a store from my understanding. This is not a Sveltekit project. Purely on clientside.

Did you find this page helpful?