Skip to content

Deploy React Router v7

Stackpad supports React Router v7 in framework mode with server-side rendering.

Quick deploy

  1. Push your React Router v7 project to GitHub
  2. Create a new project on Stackpad and select your repo
  3. Stackpad detects the framework from your dependencies
  4. Your app is live at your-project.your-org.stackpad.eu

Configuration

Make sure your package.json has build and start scripts:

{
"scripts": {
"build": "react-router build",
"start": "react-router-serve ./build/server/index.js"
}
}

The default port is 3000.

Environment variables

Access environment variables in loaders and actions:

export async function loader() {
const apiUrl = process.env.API_URL;
// ...
}

Database

Add PostgreSQL to your project and redeploy to get DATABASE_URL:

import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
export async function loader() {
const result = await pool.query('SELECT * FROM users');
return { users: result.rows };
}

What’s next?