@fjall/payload
v0.96.0
Published
Fjall AWS adapters and utilities for Payload CMS
Keywords
Readme
@fjall/payload
AWS Lambda adapters for Payload CMS. This package provides drop-in replacements for Payload's database and storage adapters, optimized for serverless deployments on AWS.
Installation
pnpm add @fjall/payload @payloadcms/storage-s3Features
fjallPostgresAdapter- PostgreSQL adapter with AWS Secrets Manager integrationawsS3Storage- S3 storage plugin for media uploadsfjallDefaults- Sensible CORS/CSRF defaults for LambdaisProduction/isLambda- Environment detection helpers
Usage
Database Adapter
// payload.config.ts
import { buildConfig } from "payload";
import { fjallPostgresAdapter, fjallDefaults } from "@fjall/payload";
import { migrations } from "./migrations";
export default buildConfig({
...fjallDefaults(),
db: await fjallPostgresAdapter({
migrationDir: "./src/migrations",
prodMigrations: migrations,
}),
// ... rest of config
});The adapter automatically:
- Fetches database credentials from AWS Secrets Manager in Lambda
- Falls back to
DATABASE_URLfor local development - Configures SSL for Aurora PostgreSQL
S3 Storage Plugin
// plugins/index.ts
import { awsS3Storage } from "@fjall/payload";
import { Plugin } from "payload";
export const plugins: Plugin[] = [awsS3Storage()];The plugin automatically:
- Uses
MEDIA_BUCKET_NAMEenvironment variable set by Fjall infrastructure - Handles presigned URLs for uploads
- Falls back to local filesystem in development
Environment Detection
import { isProduction, isLambda } from "@fjall/payload";
// Conditional logic based on environment
if (isProduction()) {
// Running in AWS with Fjall infrastructure
}
if (isLambda()) {
// Running in AWS Lambda runtime
}Conditional Static Directory
For Media collections that need local uploads in dev but S3 in production:
import { isProduction } from "@fjall/payload";
import path from "path";
export const Media: CollectionConfig = {
slug: "media",
upload: {
...(isProduction()
? {}
: {
staticDir: path.resolve(__dirname, "../../public/media"),
}),
},
};Environment Variables
Production (Lambda)
Set automatically by Fjall infrastructure:
| Variable | Description |
| ------------------- | ----------------------------- |
| DATABASE_HOST | Aurora PostgreSQL endpoint |
| DATABASE_PORT | Database port (default: 5432) |
| DATABASE_NAME | Database name |
| DATABASE_SSL | Enable SSL (true) |
| MEDIA_BUCKET_NAME | S3 bucket for uploads |
Credentials fetched from Secrets Manager:
DATABASE_USERNAMEDATABASE_PASSWORD
Development
| Variable | Description |
| -------------- | --------------------------------- |
| DATABASE_URL | Full PostgreSQL connection string |
Auto-Configuration
When you run fjall deploy on a Payload project, the CLI automatically:
- Detects the Payload pattern
- Installs
@fjall/payloadand@payloadcms/storage-s3 - Patches
payload.config.tsto usefjallPostgresAdapter - Patches or creates
plugins/index.tswith S3 storage - Configures
next.config.jsfor Lambda (standalone output) - Generates
open-next.config.tsfor OpenNext
No manual configuration required - just run fjall deploy.
Licence
Proprietary — see LICENSE.
