Deploy Files
The Deploy Files action is a server-side utility that allows platforms to programmatically deploy files to Vercel. This is the core functionality behind platforms like Mintlify and Hashnode that create Vercel deployments for their users without requiring direct Vercel account access.
Install the deploy-files action with the Vercel Platforms CLI:
npx @vercel/platforms@latest add deploy-filesYou can also install it with the shadcn CLI:
npx shadcn@latest add https://registry.platforms.guide/deploy-files.json- Programmatic deployment: Deploy files directly to Vercel using the SDK
- Custom domain support: Automatically configure custom domains for deployments
- Project configuration: Pass custom build settings and environment variables
- SSO protection handling: Optionally make preview deployments public
- Unique deployment naming: Automatic UUID generation for deployment identification
import { deployFiles } from '@/actions/deploy-files';
import type { InlinedFile } from '@vercel/sdk/models/createdeploymentop';
// Example: Deploy a simple HTML site
const files: InlinedFile[] = [
{
file: 'index.html',
data: '<html><body><h1>Hello from my platform!</h1></body></html>',
},
{
file: 'package.json',
data: JSON.stringify({
name: 'my-deployment',
version: '1.0.0',
}),
},
];
await deployFiles(files, {
domain: 'customer-site.com',
deploymentName: 'customer-deployment-1',
projectId: 'existing-project-id', // Optional: use existing project
config: {
framework: 'nextjs',
buildCommand: 'npm run build',
outputDirectory: '.next',
},
});Array of files to deploy. Can be either:
InlinedFile: File content provided directly as a stringUploadedFile: File content uploaded separately and referenced by SHA
Configuration object with the following options:
| Option | Type | Required | Description |
|---|---|---|---|
projectId | string | No | Optional existing Vercel project ID. If not provided, creates a new project |
deploymentName | string | No | Custom deployment name. Defaults to a UUID |
config | ProjectSettings | No | Build configuration including framework, commands, and environment |
domain | string | No | Custom domain to add to the project after deployment |
import { deployFiles } from '@/actions/deploy-files';
import type {
InlinedFile,
ProjectSettings,
} from '@vercel/sdk/models/createdeploymentop';
// Deploy a Next.js application with custom configuration
const files: InlinedFile[] = [
// Your application files here
];
const config: ProjectSettings = {
framework: 'nextjs',
buildCommand: 'npm run build',
outputDirectory: '.next',
installCommand: 'npm install',
devCommand: 'npm run dev',
env: {
API_KEY: 'your-api-key',
DATABASE_URL: 'your-database-url',
},
buildEnv: {
NODE_ENV: 'production',
},
};
const deployment = await deployFiles(files, {
deploymentName: `deployment-${Date.now()}`,
config,
domain: 'app.customer-domain.com',
});After creating a deployment with this action, you typically show the Claim Deployment component to allow users to take ownership:
// 1. Deploy files server-side
const deployment = await deployFiles(files, { domain })
// 2. Show claim interface client-side
<ClaimDeployment
url={deployment.url}
onClaimClick={handleTransferOwnership}
/>- This action requires Vercel API credentials with deployment permissions
- Always validate and sanitize file contents before deployment
- Consider implementing rate limiting to prevent abuse
- Store API credentials securely using environment variables
Was this helpful?