diff --git a/docs/content/docs/6.deploy/8.aws-amplify.md b/docs/content/docs/6.deploy/8.aws-amplify.md index 5de3f5fe7..e47644ed6 100644 --- a/docs/content/docs/6.deploy/8.aws-amplify.md +++ b/docs/content/docs/6.deploy/8.aws-amplify.md @@ -6,8 +6,10 @@ description: Deploy your Content app to AWS Amplify ::card Quick Setup -- Install `sqlite3` package in your project. -- Go to AWS Amplify dashboard and create a new project using git repository and deploy the app. +- Prepare Sqlite Connector + - Option A (recommended on Node.js 22+): Use native `node:sqlite` + - Option B (legacy): Install `sqlite3` package in your project. +- Go to AWS Amplify dashboard and create a new project using your git repository and deploy the app. :: :hr @@ -15,6 +17,26 @@ Quick Setup Nuxt Content projects can be deployed to AWS Amplify with zero configuration. The module will automatically detect an AWS Amplify environment and will prepare the necessary configuration for deployment. +## Option A: Use native `node:sqlite` + +In order to use native `node:sqlite` package, you need to change node version to 22+. This can be easily done +in Amplify dashboard via `Build Settings` > `Live Package Updates` > `Package (Node.js version) = 22`. + +This is also possible via `amplify.yml` inside `preBuild` phase. + +```yml +frontend: + phases: + preBuild: + commands: + - nvm install 22 + - nvm use 22 + - node -v + - npm ci +``` + +## Option B: Use `sqlite3` + All you need to do is to install `sqlite3` package in your project and go to AWS Amplify dashboard and create a new project using git repository. That's it :tada: diff --git a/src/presets/aws-amplify.ts b/src/presets/aws-amplify.ts index bc197eea2..e0174488b 100644 --- a/src/presets/aws-amplify.ts +++ b/src/presets/aws-amplify.ts @@ -1,6 +1,7 @@ import { definePreset } from '../utils/preset' import { logger } from '../utils/dev' import nodePreset from './node' +import { isNodeSqliteAvailable } from '../utils/dependencies' export default definePreset({ name: 'aws-amplify', @@ -17,10 +18,15 @@ export default definePreset({ }) try { - await import('sqlite3') - options.experimental ||= {} - options.experimental.sqliteConnector = 'sqlite3' + if (isNodeSqliteAvailable()) { + options.experimental.sqliteConnector = 'native' + } + else { + await import('sqlite3') + + options.experimental.sqliteConnector = 'sqlite3' + } } catch { logger.error('Nuxt Content requires `sqlite3` module to work in AWS Amplify environment. Please run `npm install sqlite3` to install it and try again.')