Getting Started
Configuration Reference
Full reference for nuxt.config.ts module options, TypeScript types, and sheet routing maps.
Complete reference of all configuration options, environment variables, and TypeScript interfaces available in nuxt-gsheet.
Module Options (nuxt.config.ts)
Configure nuxt-gsheet options globally in your nuxt.config.ts under the gsheet key:
nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-gsheet'],
gsheet: {
// Mode override ('apikey' | 'service-account' | 'appscript' | 'gviz' | 'csv')
auth: undefined, // Auto-detects based on env vars if omitted
// Default Spreadsheet ID
spreadsheetId: undefined,
// Google API Key (for public sheets)
apiKey: undefined,
// Google Apps Script Web App URL
appscriptUrl: undefined,
// Service Account Credentials (for private sheets)
credentials: {
clientEmail: '',
privateKey: ''
},
// Sheet Routing Map (alias key -> ID/URL/GID)
sheets: {
products: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
submissions: 'https://script.google.com/macros/s/.../exec'
},
// Cache settings
cache: {
enabled: true,
maxAge: 300, // TTL in seconds (default: 5 minutes)
storage: 'memory' // Storage driver
}
}
})
TypeScript Interfaces
1. ModuleOptions
export interface ModuleOptions {
auth?: 'apikey' | 'service-account' | 'appscript' | 'gviz' | 'csv' | 'oauth2'
apiKey?: string
spreadsheetId?: string
appscriptUrl?: string
credentials?: {
clientEmail: string
privateKey: string
}
sheets?: Record<string, string | number>
cache?: {
enabled?: boolean
maxAge?: number
storage?: 'memory' | string
}
}
2. ComposablesOptions
Passed as the second parameter to useGSheet, useGSheetAsObject, and useGSheetRow:
export interface ComposablesOptions {
sheet?: string // Target sheet tab name or alias
valueRenderOption?: 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA'
transform?: (data: any) => any // Custom server-side response transformer
cache?: boolean // Set to false to bypass cache
cacheMaxAge?: number // Override cache TTL for single request (seconds)
query?: string // GViz SQL query filter string
key?: string // Unique Nuxt useFetch cache key
}
3. GSheetWriteOptions
Passed to append, update, and clear functions from useGSheetWrite:
export interface GSheetWriteOptions {
sheet?: string
range?: string
values?: any[][]
row?: any[]
}
Sheet Routing Map (sheets)
Use the sheets property to map human-readable aliases to specific spreadsheet IDs or Apps Script URLs. This avoids hardcoding spreadsheet IDs in your composables:
nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-gsheet'],
gsheet: {
sheets: {
products: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
orders: '19rQ1234567890abcdefghijklmnopqrstuvwxyz'
}
}
})
Usage in component:
// Automatically resolves to spreadsheet ID for 'products'
const { data: products } = await useGSheetAsObject('A1:C20', {
sheet: 'products'
})