NetlifyDeployer ✅
The NetlifyDeployer deploys Kastrax applications to Netlify Functions, handling site creation, configuration, and deployment processes. It extends the abstract Deployer class to provide Netlify-specific deployment functionality.
Usage Example ✅
import { Kastrax } from '@kastrax/core';
import { NetlifyDeployer } from '@kastrax/deployer-netlify';
const kastrax = new Kastrax({
deployer: new NetlifyDeployer({
scope: 'your-team-slug',
projectName: 'your-project-name',
token: 'your-netlify-token'
}),
// ... other Kastrax configuration options
});
Parameters ✅
Constructor Parameters
scope:
projectName:
token:
Environment Variables
The NetlifyDeployer handles environment variables from multiple sources:
- Environment Files: Variables from
.env.production
and.env
files. - Configuration: Variables passed through the Kastrax configuration.
- Netlify Dashboard: Variables can also be managed through Netlify’s web interface.
Build Kastrax Project ✅
To build your Kastrax project for Netlify deployment:
npx kastrax build
The build process generates the following output structure in the .kastrax/output
directory:
.kastrax/output/
├── netlify/
│ └── functions/
│ └── api/
│ └── index.mjs # Application entry point
└── netlify.toml # Netlify configuration
Netlify Configuration
The NetlifyDeployer automatically generates a netlify.toml
configuration file in .kastrax/output
with the following settings:
[functions]
node_bundler = "esbuild"
directory = "netlify/functions"
[[redirects]]
force = true
from = "/*"
status = 200
to = "/.netlify/functions/api/:splat"
Deployment Options ✅
After building, you can deploy your Kastrax application .kastrax/output
to Netlify using any of these methods:
-
Netlify CLI: Deploy directly using Netlify’s official CLI tool
- Install the CLI:
npm install -g netlify-cli
- Navigate to the output directory:
cd .kastrax/output
- Deploy with functions directory specified:
netlify deploy --dir . --functions ./netlify/functions
- For production deployment add
--prod
flag:netlify deploy --prod --dir . --functions ./netlify/functions
- Install the CLI:
-
Netlify Dashboard: Connect your Git repository or drag-and-drop the build output through the Netlify dashboard
-
Netlify Dev: Run your Kastrax application locally with Netlify’s development environment
You can also run
netlify dev
in your output directory.kastrax/output
to test your Kastrax application locally.