# Common questions (https://session-kit.pages.dev/docs/faq)

These questions come up when you adopt Session kit. Each answer is short, and
links to the page that covers the subject in full.

## Do I need a refresh token?

No. Without a refresh token or a `refresh` callback, the user is signed out
when the access token expires, or when `authFetch` gets a 401. See
[Authenticated requests](https://session-kit.pages.dev/docs/client/requests) for what happens after a 401,
and [Refresh](https://session-kit.pages.dev/docs/configuration/refresh) to add a refresh later.

## What if my backend doesn't say when the token expires?

The client still works. See [Expiry](https://session-kit.pages.dev/docs/configuration/expiry) for where
the client looks for the expiry, and what it does when it finds none.

## Is it safe to keep tokens in `localStorage`?

Any script on your origin can read them, as [Security](https://session-kit.pages.dev/docs/security)
explains. If that isn't acceptable for your app, you have two options:

- Keep the session on the server, in an `httpOnly` cookie, with
  [server rendering](https://session-kit.pages.dev/docs/server-rendering).
- Keep the tokens off disk with `memoryStorage()`. The session then ends when
  the page unloads. See [Storage](https://session-kit.pages.dev/docs/configuration/storage).

## How do I use it with TanStack Query, or another cache?

Put [`state.sessionId`](https://session-kit.pages.dev/docs/client/state) in the query key, or clear the
cache when it changes, so one account never reads another's data. With
effetch-query, [`resetKey`](https://session-kit.pages.dev/docs/effect#cache-with-effetch-query) does it.

## Why does TanStack Start in SPA mode flash my pending component?

The build prerenders an HTML shell, which the browser shows before any
JavaScript runs. The client restores the session as soon as the script loads.
Plain TanStack Router shows a blank page for the same moment. Give the shell
a neutral pending component, as
[TanStack Start in SPA mode](https://session-kit.pages.dev/docs/setups/tanstack-router#tanstack-start-in-spa-mode)
does.

## What if some endpoints answer 401 for other reasons?

Turn off `signOutOnRepeated401` in `createAuthFetch`'s options. A second 401
from those endpoints then comes back to your code instead of signing the user
out. Without a refresh token or a `refresh` callback, the first 401 still
signs the user out. See
[Keep users signed in after a second 401](https://session-kit.pages.dev/docs/client/requests#keep-users-signed-in-after-a-second-401).

## How much does it add to my bundle?

About 11 kB gzipped for a single-page app with a router adapter and
`createAuthFetch`. With server rendering, where the session work happens on
the server, it's about 5 kB. The routers you don't use add nothing: see
[Entry points](https://session-kit.pages.dev/docs/reference).

## Can I sign users in with Google, or a magic link?

Yes, through your backend. Whatever your backend does to sign a user in,
Session kit starts from the tokens it answers with. See
[What it doesn't do](https://session-kit.pages.dev/docs#what-it-doesnt-do).

## Next steps

- [Security](https://session-kit.pages.dev/docs/security): what Session kit protects, and what stays your
  backend's job.
- [Compatibility](https://session-kit.pages.dev/docs/reference/compatibility): the runtimes and versions
  Session kit supports.