Files
supabase-vercel-tedd[bot]andAlexis Aguilar 78870669cd docs: say where to create the env file in the Vite quickstarts (#53768)
## Problem

The React, Vue, SolidJS and Refine quickstarts tell the reader to create
an env file but not where. The next step creates `src/lib`, so a reader
can put the file in `src/`. Vite loads env files only from the project
root by default, so `import.meta.env.VITE_SUPABASE_URL` then comes back
`undefined`.

Related to
[FDBKIN-25261](https://linear.app/supabase/issue/FDBKIN-25261/clarify-env-file-placement-in-the-react-quickstart-guide)
Closes
[DOCS-1726](https://linear.app/supabase/issue/DOCS-1726/say-where-to-create-the-env-file-in-the-vite-based-quickstarts)

## Solution

The env step of each of these four quickstarts now says to create the
file in the root of the project, next to `package.json`. It reuses the
"in the root of your project" wording that the TanStack and Expo
quickstarts already use, and `package.json` gives the reader a concrete
landmark that rules out `src/`. Only that one sentence changes on each
page.

## How to verify

On the docs preview:

1. `/docs/guides/getting-started/quickstarts/reactjs`, step 6: the first
sentence says to create `.env.local` in the root of your project, next
to `package.json`.
2. `/docs/guides/getting-started/quickstarts/vue`, step 6: same for
`.env.local`.
3. `/docs/guides/getting-started/quickstarts/solidjs`, step 6: same for
`.env.local`.
4. `/docs/guides/getting-started/quickstarts/refine`, step 5: same for
`.env`.
5. No other text on these pages changes.

## Checks

Ran `pnpm turbo run typecheck --filter='...[origin/master]'`, `pnpm
turbo run lint --filter='[origin/master]'` (0 errors), and Prettier on
the four changed files; all pass. Checked against Vite's `envDir` option
(defaults to the project root) and confirmed each page scaffolds a Vite
app. Skipped the docs unit tests: they need Docker.

## Second reader

Verdict: ready, no blockers. One nit: "project" could be read as the
Supabase project, since the same sentence mentions the project Connect
panel. Kept the wording, because "next to `package.json`" settles it and
it matches the sibling quickstarts. Pre-existing issues it noted outside
this change: "populate with" missing "it" on the Vue and SolidJS pages,
missing end punctuation on the React sentence, and the same missing
location in several framework tutorials and the Astro and Nuxt
quickstarts.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
Co-authored-by: Alexis Aguilar <98043211+alexisintech@users.noreply.github.com>
2026-11-23 13:53:35 -07:00

121 lines
3.4 KiB
Plaintext

---
title: 'Use Supabase with SolidJS'
subtitle: 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a SolidJS app.'
breadcrumb: 'Framework Quickstarts'
---
<AiPrompt id="solidjs" />
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a SolidJS app
Create a SolidJS app using the `degit` command.
```bash
npx degit solidjs/templates/vanilla/basic my-app
```
The template ships with a `pnpm-lock.yaml`. Remove it so `npm install` in the next steps doesn't create a second, conflicting lockfile:
```bash
rm my-app/pnpm-lock.yaml
```
## 4. Set up AI tooling (optional)
<$Partial path="quickstart_ai_tooling.mdx" />
## 5. Install the Supabase client library
The fastest way to get started is to use the `supabase-js` client library which provides a convenient interface for working with Supabase from a SolidJS app.
Navigate to the SolidJS app and install `supabase-js`.
```bash
cd my-app && npm install @supabase/supabase-js
```
## 6. Declare Supabase environment variables
Create a `.env.local` file in the root of your project, next to `package.json`, and populate with your Supabase connection variables that you can get from the helper below, or [from the project **Connect** panel](/dashboard/project/_?showConnect=true&framework=solidjs&connectTab=frameworks):
<Button variant="primary" asChild>
<a href="/dashboard/project/_?showConnect=true&connectTab=frameworks&framework=solidjs">
Open Connect panel
</a>
</Button>
```dotenv name=.env.local
VITE_SUPABASE_URL=<SUBSTITUTE_SUPABASE_URL>
VITE_SUPABASE_PUBLISHABLE_KEY=<SUBSTITUTE_SUPABASE_PUBLISHABLE_KEY>
```
<$Partial path="api_settings.mdx" variables={{ "framework": "solidjs", "tab": "frameworks" }} />
## 7. Create the Supabase client
Create a `src/lib` directory in your SolidJS app, create a file called `supabaseClient.ts`, and add the following code to initialize the Supabase client:
```ts name=src/lib/supabaseClient.ts
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
const supabasePublishableKey = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY
export const supabase = createClient(supabaseUrl, supabasePublishableKey)
```
## 8. Query data from the app
In `src/App.tsx`, add a `getInstruments` function to fetch the data and display the query result to the page.
```tsx name=src/App.tsx
import { createResource, For, Show } from 'solid-js'
import { supabase } from './lib/supabaseClient'
async function getInstruments() {
const { data, error } = await supabase.from('instruments').select()
if (error) {
throw error
}
return data
}
function App() {
const [instruments] = createResource(getInstruments)
return (
<Show
when={!instruments.error}
fallback={<p>Error loading instruments: {instruments.error?.message}</p>}
>
<ul>
<For each={instruments()}>{(instrument) => <li>{instrument.name}</li>}</For>
</ul>
</Show>
)
}
export default App
```
## 9. Start the app
Start the app and go to http://localhost:3000 in a browser and you should see the list of instruments.
```bash
npm run dev
```
<$Partial path="quickstart_going_to_production.mdx" />
## Next steps
- 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)