-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# How to get query strings in Astro | ||
|
||
You can get the query string using [`Astro.url`](https://docs.astro.build/en/reference/api-reference/#astrourl) - | ||
|
||
```js | ||
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](https://docs.astro.build/en/guides/server-side-rendering/) by changing `output: 'server'` in the config file or set `export const prerender = false;` on top of the page or route. |