Nuxt - Laravel Precognition
GitHubNuxt Module
  • Getting Started
    • Introduction
    • Installation
  • Usage
    • Configuration
  • Validation
  • Error handling
  • File uploads
  • Use with Nuxt UI
  • Composables
    • usePrecognitionForm
    • usePrecognitionConfig
    • useNuxtFormValidator
  • Other
    • Breeze Nuxt template
    • Troubleshooting
Powered by GitBook
On this page
  • Default configuration
  • Overrides
  • Environment variables
  • Available options
  1. Usage

Configuration

Detailed description of available module options.

Default configuration

By default, the module uses the following configuration values that you can adjust:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-sanctum-precognition'],

  precognition: {
    validateFiles: false,
    validationTimeout: 500,
    logLevel: 3,
  },
});

If you don't specify any value in your nuxt.config.ts, then the default config will be used on module initialization.

Overrides

Module configuration is exposed to runtimeConfig property of your Nuxt app, so you can override either in precognition module config or runtimeConfig.public.precognition property.

export default defineNuxtConfig({
  modules: ['nuxt-sanctum-precognition'],
  
  precognition: {
    validateFiles: false,
  },

  runtimeConfig: {
    public: {
      precognition: {
        validateFiles: true, // overrides previous value
      },
    },
  },
});

Environment variables

It is possible to override options via environment variables too. It might be useful when you want to use .env file to provide key for the broadcast backend.

And here is what it will look like in .env file:

.env
NUXT_PUBLIC_PRECOGNITION_VALIDATE_FILES=true

Available options

For any additional configurations, you can adjust the next list of available parameters:

Parameter
Description
Default value

validateFiles

Whether to send files when validating the form on every request.

true

validationTimeout

The duration in milliseconds to wait before validating the form.

500

logLevel

The log level to use for the logger.

3

PreviousInstallationNextValidation

Last updated 2 months ago