Module options
Nuxt Neon can be configured by a set of options.
Options can be set either by overriding the default options values using key neon inside nuxt.config.ts:
export default defineNuxtConfig({
neon: {
neonSSLMode: 'verify-full',
neonDebugSQL: true,
neonDebugRuntime: true,
// other module overrides
},
// other configuration
})Or via env variables that are mapped into Nuxt runtime config:
NUXT_PUBLIC_NEON_SSL_MODE=verify-full
NUXT_PUBLIC_NEON_DEBUG_SQL=true
NUXT_PUBLIC_NEON_DEBUG_RUNTIME=true
# other module overridesDatabase connection
Following set of server-side only variables is used to construct the PostgreSQL connection string into your Neon database:
NUXT_NEON_HOST=your-neon-host
NUXT_NEON_USER=your-neon-user
NUXT_NEON_PASS=your-neon-password
NUXT_NEON_DB=your-neon-databaseThose values can only be passed as env variables and cannot be set via module options in nuxt.config.ts. This should prevent you from being tempted to hardcode them into source code and accidentaly leak them by pushing into Git repository.
WARNING
Of course, you must also avoid to commit your .env file with sensitive values into Git repository!
Server-side options
Following options only affect server-side behavior and the values are not exposed to client-side.
neonAllowedTables
Comma-separated list of tables allowed for querying. By default, it is allowed to query all user-defined tables. You may either lift the restriction imposed on system tables or limit access only to specified list of tables.
Possible values:
NEON_PUBLIC- all user-defined tables (default)NEON_ALL- all tables includingpg_*andinformation_schema.*system tables- comma-separated list of table names (eg.
products,orders)
Special usage notes:
- special values can be combined with specific table names via comma-separation (eg.
NEON_PUBLIC,pg_database,information_schema.sql_features) - adding a system table will override
NEON_PUBLICfor this particular table - if schema is used for a table (see here), allowed value must contain it exactly (eg.
schema.products,schema.orders)
export default defineNuxtConfig({
neon: {
neonAllowedTables: 'products,orders',
},
})NUXT_NEON_ALLOWED_TABLES='products,orders'neonAllowedQueries
Semicolon-separated list of SQL queries allowed to be executed via raw SQL wrapper.
Possible values:
''- no raw queries are allowed (default)NEON_ALL- any valid SQL query can be executed (extra discouraged)- semicolon-separated list of raw SQL queries (eg.
SELECT * FROM users;SELECT * FROM products)
Special usage notes:
- This option is only relevant if
neonExposeRawEndpointistrue. Otherwise the raw endpoint is blocked completely.
WARNING
You should only use this as a last resort for use-cases that cannot be covered by other SQL wrappers while requesting and waiting for the fix.
export default defineNuxtConfig({
neon: {
neonAllowedQueries: 'SELECT * FROM users;SELECT * FROM products',
},
})NUXT_NEON_ALLOWED_QUERIES='SELECT * FROM users;SELECT * FROM products'Public options
Following options are available at both server and client side.
neonDB
Neon database name (your database name) which WILL BE exposed to client-side.
Possible values:
- string (eg.
my_database)
Special usage notes:
- this will allow to disclose your database name on client side, which you might or might not want to do
- it will appear in result of
neonStatusonce set - when building DB connection string, module uses
NUXT_NEON_DBenv value and NOT this - the value may differ from the actual
NUXT_NEON_DBenv value
export default defineNuxtConfig({
neon: {
neonDB: 'SELECT * FROM users;SELECT * FROM products',
},
})NUXT_PUBLIC_NEON_DB='my_database'neonSSLMode
Allows setting secure connection mode when constructing the DB connection string by adding sslmode parameter to
Possible values:
require(default)verify-caverify-fullnone(sslmode is not inclued in the connection string)
export default defineNuxtConfig({
neon: {
neonSSLMode: 'verify-ca',
},
})NUXT_PUBLIC_NEON_SSL_MODE='verify-ca'neonDebugSQL
If set to true, the actual SQL query produced is captured and attached to error responses.
Possible values:
truefalse(default)
export default defineNuxtConfig({
neon: {
neonDebugSQL: true,
},
})NUXT_PUBLIC_NEON_DEBUG_SQL=trueneonDebugRuntime
If set to true, extra runtime information is captured and logged.
Possible values:
truefalse(default)
export default defineNuxtConfig({
neon: {
neonDebugRuntime: true,
},
})NUXT_PUBLIC_NEON_DEBUG_RUNTIME=trueneonExposeEndpoints
If set to true, Nuxt Neon can be used client-side via exposed API endpoints.
DANGER
Exposing your connection client-side is DANGEROUS and highly DISCOURAGED.
See here for more details.
Possible values:
truefalse(default)
export default defineNuxtConfig({
neon: {
neonExposeEndpoints: true,
},
})NUXT_PUBLIC_NEON_EXPOSE_ENDPOINTS=trueneonExposeRawEndpoint
If set to true, raw SQL wrapper can be used.
DANGER
Allowing any valid SQL query to run directly is DANGEROUS and highly DISCOURAGED.
See here for more details.
Possible values:
truefalse(default)
Special usage notes:
- even if
neonExposeEndpointsisfalse, setting this totruewill allowrawqueries server-side - even if
neonExposeEndpointsistrue, you still need to set this one totrueas well to allowrawqueries client-side - you still need to set allowed queries via
neonAllowedQueriesbefore running raw queries
export default defineNuxtConfig({
neon: {
neonExposeRawEndpoint: true,
},
})NUXT_PUBLIC_NEON_EXPOSE_RAW_ENDPOINT=true