```
<$Partial path="api_settings.mdx" variables={{ "framework": "sveltekit", "tab": "frameworks" }} />
## 7. Create the Supabase client [#create-the-client]
In your SvelteKit app, create a `src/lib` directory, create a file called `supabaseClient.js`, and add the following code to initialize the Supabase client:
<$CodeTabs>
```js name=src/lib/supabaseClient.js
import { createClient } from '@supabase/supabase-js'
import { PUBLIC_SUPABASE_PUBLISHABLE_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public'
export const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_PUBLISHABLE_KEY)
```
```ts name=src/lib/supabaseClient.ts
import { createClient } from '@supabase/supabase-js'
import { PUBLIC_SUPABASE_PUBLISHABLE_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public'
export const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_PUBLISHABLE_KEY)
```
$CodeTabs>
## 8. Query data from the app [#query-data]
Use the `load` function to fetch the data server-side and display the query results as a list.
In the `src/routes` directory, create a `+page.server.js` file with the following code.
<$CodeTabs>
```js name=src/routes/+page.server.js
import { supabase } from '$lib/supabaseClient'
export async function load() {
const { data, error } = await supabase.from('instruments').select()
if (error) {
console.error('Error loading instruments:', error.message)
return { instruments: [], error: error.message }
}
return {
instruments: data ?? [],
error: null,
}
}
```
```ts name=src/routes/+page.server.ts
import { supabase } from '$lib/supabaseClient'
import type { PageServerLoad } from './$types'
type Instrument = {
id: number
name: string
}
export const load: PageServerLoad = async () => {
const { data, error } = await supabase.from('instruments').select<'*', Instrument>()
if (error) {
console.error('Error loading instruments:', error.message)
return { instruments: [], error: error.message }
}
return {
instruments: data ?? [],
error: null,
}
}
```
$CodeTabs>
In `src/routes/+page.svelte`, replace the existing content with the following code.
```svelte name=src/routes/+page.svelte
{#if data.error}
Error loading instruments: {data.error}
{:else}
{#each data.instruments as instrument}
- {instrument.name}
{/each}
{/if}
```
## 9. Start the app [#start-the-app]
Start the app and go to `http://localhost:5173` in a browser. The page lists the instruments.
```bash
npm run dev
```
<$Partial path="quickstart_going_to_production.mdx" />
## Next steps
Build on this app with the following resources:
- Set up [Auth](/docs/guides/auth) for your app
- [Insert more data](/docs/guides/database/import-data) into your database
- Upload and serve static files using [Storage](/docs/guides/storage)