Installation
Get started with nuxt-gsheet by installing the package, registering the module in your Nuxt configuration, and setting up environment variables.
Package Installation
Add nuxt-gsheet to your project using your preferred package manager:
npx nuxt module add gsheet
bun add nuxt-gsheet
pnpm add nuxt-gsheet
npm install nuxt-gsheet
yarn add nuxt-gsheet
Registering the Module
Add nuxt-gsheet to the modules array in your nuxt.config.ts:
export default defineNuxtConfig({
modules: [
'nuxt-gsheet'
],
gsheet: {
// Module default options (optional)
cache: {
enabled: true,
maxAge: 300 // 5 minutes cache TTL
}
}
})
Environment Configuration
Configure your Google Sheets credentials or spreadsheet settings in your .env file at the root of your project. nuxt-gsheet automatically detects the authentication mode based on the environment variables defined below.
Option 1: Google Apps Script Mode (appscript)
Use Google Apps Script to proxy requests without creating Google Cloud Platform (GCP) credentials. Supports both Read and Write operations.
GSHEET_APPSCRIPT_URL=https://script.google.com/macros/s/AKfycb.../exec
Option 2: Public Spreadsheet Modes (gviz or csv)
Use GViz or direct CSV export for zero-config, read-only access to public spreadsheets. No API keys or GCP credentials required.
GSHEET_SPREADSHEET_ID=your-google-spreadsheet-id
Option 3: API Key Mode (apikey)
Use standard Google Sheets API v4 for public spreadsheets with custom quota control.
GSHEET_SPREADSHEET_ID=your-google-spreadsheet-id
GSHEET_API_KEY=AIzaSy...
Option 4: Service Account Mode (service-account)
Use GCP Service Account credentials for private Google Sheets. Supports Read and Write operations.
GSHEET_SPREADSHEET_ID=your-google-spreadsheet-id
GSHEET_CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
GSHEET_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n"
Always keep your .env file in .gitignore. Never commit private keys or API credentials to version control.
Verifying Your Setup
To verify that nuxt-gsheet is set up correctly:
- Start your local Nuxt development server:
bun run dev
- Open your browser and launch Nuxt DevTools (
Shift + Alt + Dor click the Nuxt icon at the bottom of the screen). - Look for the Google Sheets tab in the DevTools menu. If visible, the module has loaded successfully.