Deploying a RedwoodJS App
RedwoodJS is a full-stack JavaScript/TypeScript framework designed for building and deploying modern web applications with ease. It features a monorepo structure, built-in GraphQL API, and seamless integration between frontend and backend, making it ideal for startups and teams who want to move fast with best practices out of the box.
This guide explains how to deploy a RedwoodJS application to Klutch.sh, both with and without a Dockerfile. It also covers installation and provides sample code to get started.
Prerequisites
- Node.js 18+
- Git and GitHub account
- Klutch.sh account
Getting Started: Install Redwood
- Create a new Redwood app:
Terminal window npm create redwood-app@latest my-redwood-appcd my-redwood-appnpm install - Start the development server:
Your app should be running at http://localhost:8910.
Terminal window yarn redwood dev# ornpm run redwood dev
Sample Code (web/src/pages/HomePage/HomePage.tsx or HomePage.js)
Add a simple page to your Redwood project:
const HomePage = () => { return ( <div> <h1>Hello from Redwood on Klutch.sh!</h1> <p>This is your starter page.</p> </div> );};export default HomePage;
Deploying Without a Dockerfile
- Push your Redwood app to a GitHub repository.
- Log in to Klutch.sh.
- Create a new project and give it a name.
- Create a new app:
- Select your Redwood GitHub repository and branch
- Set the port to route traffic (usually 8910 for Redwood)
- Choose region, compute, number of instances, and add any environment variables
- Add a start script in your
package.json
:Or, if using npm:"scripts": {"start": "yarn redwood serve"}"scripts": {"start": "npm run redwood serve"} - Make sure your server listens on the port provided by Klutch.sh via the
PORT
environment variable (Redwood will handle this automatically). - Click “Create” to deploy. Klutch.sh will build and deploy your app automatically.
Deploying With a Dockerfile
- Add a
Dockerfile
to your project root. Example:# Use official Node.js imageFROM node:18-alpine# Set working directoryWORKDIR /app# Copy package files and install dependenciesCOPY package*.json ./RUN npm install --production# Copy app sourceCOPY . .# Build Redwood appRUN yarn redwood build# Expose port (match your Redwood app)EXPOSE 8910# Start the appCMD ["yarn", "redwood", "serve"] - Push your code (with Dockerfile) to GitHub.
- In Klutch.sh, follow the same steps to create a project and app, but select the Dockerfile option when prompted.
- Set the service details and environment variables as needed.
- Click “Create” to deploy. Klutch.sh will build your Docker image and deploy your app.
Note: Your Redwood app should always listen on the PORT
environment variable as shown above if using a custom server.
Resources
Deploying to Klutch.sh is simple and flexible. Choose the method that best fits your workflow and project requirements.