Files
supabase/web/docs/gotrue/client/initializing.mdx
T

254 lines
4.4 KiB
Plaintext

---
id: initializing
title: "Initializing"
slug: initializing
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Create a new client for use in the browser.
<Tabs
defaultValue="js"
groupId="libraries"
values={[{ label: 'JavaScript', value: 'js' },{ label: 'Python', value: 'py' }]}>
<TabItem value="js">
```js
import { GoTrueClient } from '@supabase/gotrue-js'
const auth = new GoTrueClient({
url: "https://your-gotrue-url.com",
headers: {
apikey:
"<SOME-API-KEY>",
Authorization:
"Bearer <SOME-JWT>",
},
})
```
</TabItem>
<TabItem value="py">
```py
# Not yet implemented
```
</TabItem>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
object
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
autoRefreshToken
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
| |
</span>
</h4>
<div class="method-list-item-description">
Set to "true" if you want to automatically refresh the token before expiring.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
detectSessionInUrl
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
| |
</span>
</h4>
<div class="method-list-item-description">
Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
headers
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
|
</span>
</h4>
<div class="method-list-item-description">
Any additional headers to send to the GoTrue server.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
localStorage
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
Storage
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
persistSession
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
| |
</span>
</h4>
<div class="method-list-item-description">
Set to "true" if you want to automatically save the user session into local storage.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
url
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
|
</span>
</h4>
<div class="method-list-item-description">
The URL of the GoTrue server.
</div>
</li>
</ul>
</li>
</ul>
## Examples
### Initialize a GoTrue client
<Tabs
defaultValue="js"
groupId="libraries"
values={[{ label: 'JavaScript', value: 'js' },{ label: 'Python', value: 'py' }]}>
<TabItem value="js">
```js
import { GoTrueClient } from '@supabase/gotrue-js'
const auth = new GoTrueClient({
url: "https://your-gotrue-url.com",
headers: {
apikey:
"<SOME-API-KEY>",
Authorization:
"Bearer <SOME-JWT>",
},
})
```
</TabItem>
<TabItem value="py">
```py
# Not yet implemented
```
</TabItem>
</Tabs>