Skip to content

daaru00/nuxt3-lambda

Repository files navigation

Nuxt 3 On Lambda

Minimal Starter

Look at the documentations below to learn more:

Setup

Make sure to install the dependencies:

# yarn
yarn install

# npm
npm install

# pnpm
pnpm install

Development Server

Start the development server on http://localhost:3000

npm run dev

Production

Build the application for production:

npm run build

Locally preview production build:

npm run preview

Deploy

Build the application before every sam deploy using Lambda preset:

NITRO_PRESET=aws-lambda npm run build

Before every SAM deploy uploads the static files to the S3 bucket:

aws --profile <profile name> --region <region> s3 cp --recursive .output/public s3://<bucket name>/

Executing the first deploy for the SAM applications:

sam deploy --profile <profile name> --region <region> --guided

for subsequent deploys of application SAM:

sam deploy

Invalidate CloudFront cache in front of Nuxt3 application:

aws --profile <profile name> --region <region> cloudfront create-invalidation --distribution-id <distribution id> --paths '/*'

Automatic frontend deploy

Build the application before every sam deploy using Lambda preset:

NITRO_PRESET=aws-lambda npm run build

Execute a SAM deploy configuring "AutoDeploy" parameter:

sam deploy --parameter-overrides AutoDeploy=ENABLED

The frontend application files will be uploaded from a Lambda function and, when finished, the CloudFront cache will be invalidated.