diff --git a/apps/docs/pages/guides/getting-started/quickstarts/nuxtjs.mdx b/apps/docs/pages/guides/getting-started/quickstarts/nuxtjs.mdx index f9259185926..60c3a3ee0f5 100644 --- a/apps/docs/pages/guides/getting-started/quickstarts/nuxtjs.mdx +++ b/apps/docs/pages/guides/getting-started/quickstarts/nuxtjs.mdx @@ -2,79 +2,54 @@ import Layout from '~/layouts/DefaultGuideLayout' import StepHikeCompact from '~/components/StepHikeCompact' export const meta = { - title: 'Install Supabase with Nuxt.js', - subtitle: 'Setting up supabase-js client library in a Nuxt.js app.', + title: 'Use Supabase with NuxtJS', + subtitle: + 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a NuxtJS app.', + breadcrumb: 'Framework Quickstarts', } -The fastest way to get started with supabase and Nuxt.js is to use the supabase-js client library, which provides a convenient interface for working with supabase from a Nuxt.js app. To use supabase-js with Nuxt.js, you can follow these steps: - + - + [Create a new project](https://app.supabase.com) in the Supabase Dashboard. - Start by creating a new Nuxt.js project if you do not have one set up: + After your project is ready, create a table in your Supabase database using the [SQL Editor](https://app.supabase.com/project/_/sql) in the Dashboard. Use the following SQL statement to create a `countries` table with some sample data. - ```bash Terminal - npx create-nuxt-app my-project - cd my-project - ``` + ```sql Editor + -- Create the table + create table countries ( + id serial primary key, + name varchar(255) not null + ); + + -- Insert some sample data into the table + insert into countries (name) values ('United States'); + insert into countries (name) values ('Canada'); + insert into countries (name) values ('Mexico'); + ```` - - To install the `@supabase/supabase-js` package, you will need to run the following command: + + + Create a Nuxt.js app using the `npx nuxi` command. ```bash Terminal - npm install @supabase/supabase-js - ``` - - - - - - - - - And finally we want to save the environment variables in a .env. All we need are the API URL and the anon key that you copied earlier. - - - - - - ```text .env - SUPABASE_URL="YOUR_SUPABASE_URL" - SUPABASE_KEY="YOUR_SUPABASE_ANON_KEY" - ``` - - - - - - - - - Then let's install the only additional dependency: NuxtSupabase. We only need to import NuxtSupabase as a dev dependency: - - - - - - ```bash Terminal - npm install @nuxtjs/supabase --save-dev + npx nuxi@latest init my-app ``` @@ -82,34 +57,65 @@ The fastest way to get started with supabase and Nuxt.js is to use the supabase- - + - To create a table of countries with their timezones, you will first need to create a table in your Supabase database using SQL. You can use the following SQL statement to create a table called countries: + 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 NuxtJS app. + + Navigate to the NuxtJS app and install `supabase-js`. - ```sql SQL_EDITOR - -- this creates the table - CREATE TABLE countries ( - id SERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL - ); - -- insert some sample data into new table - INSERT INTO countries (name) VALUES ('United States'); - INSERT INTO countries (name) VALUES ('Canada'); - INSERT INTO countries (name) VALUES ('Mexico'); - ```` + ```bash Terminal + cd my-app && npm install @supabase/supabase-js + ``` - + - Start the dev server by running the following commands: + In `src/App.vue`, create a Supabase client using your [Project URL and public API (anon) key](https://app.supabase.com/project/_/settings/api). + + Replace the existing content in your `src/App.vue` file with the following code. + + + + + + ```vue src/App.vue + + + + ``` + + + + + + + + + Start the app, navigate to http://localhost:3000 in the browser, open the browser console, and you should see the list of countries. @@ -122,26 +128,6 @@ The fastest way to get started with supabase and Nuxt.js is to use the supabase- - - - - - Next, in your Nuxt.js app, create a file called supabase-client.js and add the following code to initialize the Supabase client and set your project's credentials: - - - - - - ```js lib/supabaseClient.js - import { createClient } from '@supabase/supabase-js' - - const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key') - ``` - - - - - export const Page = ({ children }) =>