How to get query strings in Astro
You can get the query string using Astro.url
-
const token = Astro.url.searchParams.get("access_token") || "";
However, Astro builds a static site by default. So this cannot access the search params. Only a server can see the search params, since they are passed by the user when the user makes a request, and static sites are built ahead of time without knowing what search params a user might send.
Use SSR by changing output: 'server'
in the config file or set export const prerender = false;
on top of the page or route.