Discover the differences between Next.js, Astro, and Remix to find the right one for your next Strapi project.
Next.js vs Astro vs Remix: Choosing the Right Front-end Framework
When selecting a framework for your web application, it is critical to consider the developer experience that it provides. Astro, Remix, and Next.js all build on top of React to provide a more streamlined experience. They have a low learning curve, so if you’re already familiar with React, you can quickly pick them up and get started.
We evaluate each to help you decide which framework is appropriate for you, not to determine which is faster or better.
What is Astro?
Astro is a modern web framework built on React and a static site builder that requires little or no JavaScript to deliver lightning-fast, high-performance websites with a modern developer experience. It allows you to create websites using UI components from your favorite JavaScript UI frameworks such as React, Svelte, Vue, and others.
// Example of an Astro component
---
// Component imports and JavaScript execution
import { Image } from 'astro:assets';
import ReusableButton from '../components/Button.astro';
// Data fetching in the component
const response = await fetch('https://api.example.com/data');
const data = await response.json();
---
My Astro Site
Welcome to Astro!
This is a static site with minimal JavaScript
{data.items.map(item => (
{item.name}
))}
Enter fullscreen mode
Exit fullscreen mode
Astro websites are primarily static, with no JavaScript code by default. When a component (for example, image carousels, dark and light mode) requires JavaScript code to run, Astro only loads that component and any necessary dependencies. The rest of the site remains static lightweight HTML. Check out Astro’s Getting Started tutorial for an excellent introduction.
Astro is more flexible: you can build UI with any popular component library (React, Preact, Vue, Svelte, Solid, and others) or Astro’s HTML-like component syntax, similar to HTML + JSX.
Astro can build statically via SSG or deploy to SSR environments via adapters like Deno, Vercel serverless, Netlify serverless, and Node.js, with more to come.
// Path: astro.config.mjs - Configuring SSR with an adapter
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel/serverless';
import react from '@astrojs/react';
import vue from '@astrojs/vue';
// https://astro.build/config
export default defineConfig({
// Enable SSR for dynamic rendering
output: 'server',
// Deploy to Vercel serverless functions
adapter: vercel(),
// Add support for multiple UI frameworks
integrations: [react(), vue()]
});
Enter fullscreen mode
Exit fullscreen mode
What is Next.js?
Next.js is an open-source React framework for quickly creating server-rendered React applications. It adds structure and features and handles the React tooling and configuration required for your application.
// Path: pages/index.js - Next.js page component
import Head from 'next/head';
import Link from 'next/link';
import { useState } from 'react';
export default function Home({ featuredPosts }) {
const [count, setCount] = useState(0);
return (
My Next.js Website
Welcome to my website
setCount(count + 1)}>
Count: {count}
Featured Posts
{featuredPosts.map(post => (
{post.title}
))}
);
}
// Data fetching at build time
export async function getStaticProps() {
const res = await fetch('https://api.example.com/featured-posts');
const featuredPosts = await res.json();
return {
props: { featuredPosts },
// Re-generate page at most once per hour
revalidate: 3600
};
}
Enter fullscreen mode
Exit fullscreen mode
It can be used to solve common application requirements like routing, data retrieval, and integrations. Next.js was created to provide an easy-to-use development framework that would reduce the time and effort required to develop full-fledged, SSR-friendly web applications while improving the end user and developer experience. The documentation is a great place to start if you want to begin with this framework.Next.js fully embraces React Server Components (RSCs), enabling server-side data fetching directly within components. This reduces client-side JavaScript and improves performance. Also, Turbopack is now stable, offering lightning-fast bundling and significantly reducing build times for large projects.
// Path: app/dashboard/page.js - React Server Component in Next.js
// Server Component (no "use client" directive)
import { getUser } from '@/lib/auth';
import { getDashboardData } from '@/lib/data';
import DashboardMetrics from '@/components/DashboardMetrics';
import ClientSideInteractions from '@/components/ClientSideInteractions';
export default async function DashboardPage() {
// This code runs only on the server
const user = await getUser();
const { metrics, recentActivity } = await getDashboardData(user.id);
return (
Welcome back, {user.name}
{/* Server component with no client JS */}
{/* This component will be hydrated on the client */}
);
}
Enter fullscreen mode
Exit fullscreen mode
What is Remix?
Remix is an edge-native, full-stack JavaScript framework for building modern, fast, and resilient user experiences. It unifies the client and server with web standards so you can think less about code and more about your product. Remix is now React Router 7, and it continues to evolve with the latest web development trends.
// Path: app/routes/posts.$slug.jsx - A Remix route component
import { json } from '@remix-run/node';
import { useLoaderData, Form, useActionData } from '@remix-run/react';
import { getPost, addComment } from '~/models/post.server';
// Server-side data loading
export async function loader({ params }) {
const post = await getPost(params.slug);
if (!post) {
throw new Response("Not Found", { status: 404 });
}
return json({ post });
}
// Server-side form handling
export async function action({ request, params }) {
const formData = await request.formData();
const comment = formData.get('comment');
if (!comment || comment.length < 3) {
return json({ error: "Comment must be at least 3 characters" });
}
await addComment({ postSlug: params.slug, text: comment });
return json({ success: true });
}
// Client component using server data
export default function Post() {
const { post } = useLoaderData();
const actionData = useActionData();
return (
{post.title}
Leave a comment
{actionData?.error && {actionData.error}}
Submit
Comments
{post.comments.map(comment => (
{comment.text}
))}
);
}
Enter fullscreen mode
Exit fullscreen mode
Remix now supports Static Site Generation (SSG), allowing developers to pre-render pages at build time. This feature bridges the gap between Remix and frameworks like Next.js. Currently, Remix’s loaders and actions have been optimized for parallel data fetching, reducing load times for complex applications.
// Example of Static Site Generation in Remix (React Router 7)
// Path: routes/blog.static.$slug.tsx
import { json } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { getPost, getAllPostSlugs } from '~/models/post.server';
// Generate static paths at build time
export async function generateStaticParams() {
const slugs = await getAllPostSlugs();
return slugs.map(slug => ({ slug }));
}
// Load data at build time
export async function loader({ params }) {
const post = await getPost(params.slug);
if (!post) {
throw new Response("Not Found", { status: 404 });
}
return json({ post });
}
export default function BlogPost() {
const { post } = useLoaderData();
return (
{post.title}
);
}
Enter fullscreen mode
Exit fullscreen mode
Key Features
Let’s look at the key features of Astro, Remix, and Next.js to understand what makes each framework unique and how they cater to different development needs.
Astro
Zero-config: Any config explained will be handled by our astro add CLI command (i.e., add Svelte support with astro add svelte).
# Example of using the Astro CLI to add integrations
npm create astro@latest my-project
cd my-project
# Add Tailwind CSS support
npx astro add tailwind
# Add React support
npx astro add react
# Add image optimization
npx astro add image
Enter fullscreen mode
Exit fullscreen mode
Astro is UI-agnostic: meaning you can Bring Your Own UI Framework (BYOF).
---
// Path: src/pages/mixed-frameworks.astro
// Using multiple frameworks in the same page
import ReactCounter from '../components/ReactCounter.jsx';
import VueToggle from '../components/VueToggle.vue';
import SvelteCard from '../components/SvelteCard.svelte';
---
Multi-Framework Page
Using Multiple Frameworks
Enter fullscreen mode
Exit fullscreen mode
Easy to use: Astro’s goal is to be accessible to every web developer. Astro was designed to feel familiar and approachable regardless of skill level or experience with web development.
Fast by default: An Astro website can load 40% faster with 90% less JavaScript than the site built with the most popular React web framework.
Server-first: Astro leverages server-side rendering over client-side rendering as much as possible.
Content-based: Astro’s unique focus on content lets Astro make tradeoffs and deliver unmatched performance features that wouldn’t make sense for more application-focused web frameworks to implement.
Fully-featured but flexible: Astro is an all-in-one web framework with everything you need to build a website. Astro includes a component syntax, file-based routing, asset handling, a build process, bundling, optimizations, data fetching, and more. You can build great websites without ever reaching outside of Astro’s core feature set.
Server Islands: Astro now supports server-rendered components within static pages, enabling hybrid rendering for dynamic interactivity without sacrificing performance.
---
// Path: src/pages/islands-example.astro
import StaticHeader from '../components/StaticHeader.astro';
import DynamicCounter from '../components/DynamicCounter.jsx';
import HeavyDataComponent from '../components/HeavyDataComponent.jsx';
---
Islands Architecture Example
© 2025 My Website
Enter fullscreen mode
Exit fullscreen mode
Content Layer API: Expanded Content Collections allow seamless integration with external APIs and databases, making Astro more versatile for dynamic content.
// Path: src/content/config.ts
import { defineCollection, z } from 'astro:content';
// Define a schema for blog posts
const blogCollection = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
publishDate: z.date(),
author: z.string(),
featured: z.boolean().default(false),
tags: z.array(z.string()).default([])
})
});
// Export collections
export const collections = {
'blog': blogCollection
};
// src/pages/blog/[...slug].astro
---
import { getCollection, getEntry } from 'astro:content';
// Generate paths at build time
export async function getStaticPaths() {
const blogEntries = await getCollection('blog');
return blogEntries.map(entry => ({
params: { slug: entry.slug },
props: { entry }
}));
}
const { entry } = Astro.props;
const { Content } = await entry.render();
---
{entry.data.title}
By {entry.data.author} on {entry.data.publishDate.toLocaleDateString()}
Enter fullscreen mode
Exit fullscreen mode
Astro DB: Built-in database management powered by Drizzle, enabling full-stack capabilities for more complex applications.
// Path: db/schema.ts
import { defineDb, defineTable, column } from 'astro:db';
export const Users = defineTable({
columns: {
id: column.number({ primaryKey: true }),
name: column.text(),
email: column.text({ unique: true }),
created_at: column.date()
}
});
export default defineDb({
tables: { Users }
});
// src/pages/api/users.ts
import { db } from 'astro:db';
import { Users } from '../../db/schema';
export async function GET() {
const users = await db.select().from(Users);
return new Response(JSON.stringify(users), {
headers: { 'Content-Type': 'application/json' }
});
}
export async function POST({ request }) {
const { name, email } = await request.json();
const user = await db.insert(Users).values({
name,
email,
created_at: new Date()
}).returning();
return new Response(JSON.stringify(user), {
status: 201,
headers: { 'Content-Type': 'application/json' }
});
}
Enter fullscreen mode
Exit fullscreen mode
Remix
Routes: Like other frameworks, Remix allows developers to manage the different routes of their web projects using JavaScript/TypeScript files that contain handler functions. We can generate routes on our website to create files that follow the file system hierarchy of our projects, creating analog URLs for our pages. Remix routes work using the partial routing feature provided by React-Router.
// File-based routing in Remix
// Path: app/routes/_layout.tsx - Parent layout
import { Outlet, Link } from '@remix-run/react';
export default function Layout() {
return (
Home
About
Blog
{/* Child routes render here */}
© 2025 My Remix App
);
}
// app/routes/_layout.about.tsx - About page
export default function About() {
return (
About Us
Learn more about our company...
);
}
// app/routes/_layout.blog.tsx - Blog index
export default function BlogIndex() {
return (
Blog
Read our latest articles
);
}
// app/routes/_layout.blog.$slug.tsx - Dynamic blog post route
import { useParams } from '@remix-run/react';
export default function BlogPost() {
const { slug } = useParams();
return Blog Post: {slug};
}
Enter fullscreen mode
Exit fullscreen mode
Nested components: Remix allows you to manage nested pages and components. We can create a file to handle a certain route and, at the same level in the file system, a folder with the same name. All the files we create inside that folder will be nested components of the parent route instead of different pages.
Error Handling: Nested components bring another benefit: if an error occurs while rendering a certain component, it doesn’t affect the other nested parts of the page.
// Path: app/routes/dashboard.tsx - Parent dashboard route
import { Outlet } from '@remix-run/react';
export default function Dashboard() {
return (
Dashboard
Stats
Settings
);
}
// app/routes/dashboard.stats.tsx - Stats page with error boundary
import { useLoaderData } from '@remix-run/react';
export async function loader() {
// Potentially could fail
const stats = await fetchUserStats();
return { stats };
}
// This only affects this route, not parent or siblings
export function ErrorBoundary() {
return (
Error loading stats
There was a problem loading your statistics.
Try again
);
}
export default function Stats() {
const { stats } = useLoaderData();
return (
Your Statistics
{Object.entries(stats).map(([key, value]) => (
{key}
{value}
))}
);
}
Enter fullscreen mode
Exit fullscreen mode
Forms: As Remix focuses on web standards, it handles forms using native methods (POST, PUT, DELETE, PATCH) instead of JavaScript.
// app/routes/products.$id.tsx - Edit product form
import { Form, useLoaderData, useActionData, redirect } from '@remix-run/react';
import { json } from '@remix-run/node';
import { getProduct, updateProduct } from '~/models/product.server';
export async function loader({ params }) {
const product = await getProduct(params.id);
if (!product) {
throw new Response("Product not found", { status: 404 });
}
return json({ product });
}
export async function action({ request, params }) {
const formData = await request.formData();
const name = formData.get('name');
const price = parseFloat(formData.get('price'));
const errors = {};
if (!name) errors.name = "Name is required";
if (isNaN(price) || price <= 0) errors.price = "Price must be a positive number";
if (Object.keys(errors).length > 0) {
return json({ errors });
}
await updateProduct(params.id, { name, price });
return redirect('/products');
}
export default function EditProduct() {
const { product } = useLoaderData();
const actionData = useActionData();
return (
Edit Product: {product.name}
Name:
{actionData?.errors?.name && {actionData.errors.name}}
Price:
{actionData?.errors?.price && {actionData.errors.price}}
Save Changes
);
}
Enter fullscreen mode
Exit fullscreen mode
Loaders and Actions: Remix provides two different types of functions to create server-side dynamic content. The loader functions handle GET HTTP requests in the server, mainly used to get data from different sources.
// Path: app/routes/products.tsx - Loader and Action example
import { json, redirect } from '@remix-run/node';
import { useLoaderData, Form } from '@remix-run/react';
import { getProducts, createProduct } from '~/models/products.server';
// Loader for GET requests
export async function loader() {
const products = await getProducts();
return json({ products });
}
// Action for POST/PUT/DELETE requests
export async function action({ request }) {
const formData = await request.formData();
const intent = formData.get('intent');
if (intent === 'create') {
const name = formData.get('name');
const price = parseFloat(formData.get('price'));
await createProduct({ name, price });
return redirect('/products');
}
return json({ error: 'Invalid intent' });
}
export default function Products() {
const { products } = useLoaderData();
return (
Products
Add New Product
Add Product
Product List
{products.map(product => (
{product.name} - ${product.price.toFixed(2)}
))}
);
}
Enter fullscreen mode
Exit fullscreen mode
Static Site Generation (SSG): Remix now supports SSG, allowing developers to pre-render pages at build time. This feature bridges the gap between Remix and frameworks like Next.js.
Enhanced Data Fetching: Optimized loaders and actions for parallel data fetching, reducing load times for complex applications.
// Parallel data fetching in Remix
export async function loader() {
// Fetch multiple data sources in parallel
const [products, categories, featuredItems] = await Promise.all([
getProducts(),
getCategories(),
getFeaturedItems()
]);
return json({
products,
categories,
featuredItems
});
}
Enter fullscreen mode
Exit fullscreen mode
Next.js
Async Components & Data Fetching: Async components are a new technique for obtaining data for server-rendered components introduced in Next.js 13. We can render async components using Promises with async and await.
// Path: app/dashboard/page.js - Async Server Component
async function fetchDashboardData() {
const res = await fetch('https://api.example.com/dashboard', {
next: { revalidate: 60 } // Revalidate every 60 seconds
});
if (!res.ok) {
throw new Error('Failed to fetch dashboard data');
}
return res.json();
}
export default async function DashboardPage() {
// Data is fetched on the server during rendering
const data = await fetchDashboardData();
return (
Dashboard
Total Users
{data.totalUsers.toLocaleString()}
Active Subscriptions
{data.activeSubscriptions.toLocaleString()}
Revenue
${data.revenue.toLocaleString()}
);
}
Enter fullscreen mode
Exit fullscreen mode
React Server Components: Server components enable us to execute and render React components on the server side, resulting in faster delivery, a smaller JavaScript bundle, and lower client-side rendering costs.
// Path: app/products/[id]/page.js - Server Component
import { notFound } from 'next/navigation';
import AddToCartButton from '@/components/AddToCartButton'; // Client Component
import ProductReviews from '@/components/ProductReviews'; // Server Component
async function getProduct(id) {
const res = await fetch(`https://api.example.com/products/${id}`);
if (!res.ok) return null;
return res.json();
}
export default async function ProductPage({ params }) {
const product = await getProduct(params.id);
if (!product) {
notFound();
}
return (
{product.name}
${product.price.toFixed(2)}
{product.description}
{/* Client Component - will be hydrated on the client */}
{/* Server Component - no client JS needed */}
);
}
// components/AddToCartButton.js - Client Component
'use client';
import { useState } from 'react';
export default function AddToCartButton({ productId }) {
const [isAdding, setIsAdding] = useState(false);
async function handleAddToCart() {
setIsAdding(true);
await addToCart(productId);
setIsAdding(false);
}
return (
{isAdding ? 'Adding...' : 'Add to Cart'}
);
}
Enter fullscreen mode
Exit fullscreen mode
app/ Directory for File-Based Routing: Routes are defined using the structure of your project directory. By placing an entry point in the app directory, you can create a new route. This feature is now stable and fully supported for production use.
// Next.js App Router structure example
// app/page.js - Homepage
export default function HomePage() {
return Welcome to our website;
}
// app/about/page.js - About page (/about)
export default function AboutPage() {
return About Us;
}
// app/blog/[slug]/page.js - Dynamic blog post page (/blog/*)
export default function BlogPost({ params }) {
return Blog Post: {params.slug};
}
// app/api/products/route.js - API route (/api/products)
export async function GET(request) {
const products = await fetchProducts();
return Response.json(products);
}
Enter fullscreen mode
Exit fullscreen mode
Lightning Fast Bundling: Turbopack, introduced with Next.js 13, is now stable and offers lightning-fast bundling, significantly reducing build times for large projects.
// Path: next.config.js - Enabling Turbopack
/** @type {import('next').NextConfig} */
const nextConfig = {
// Enable Turbopack for development
experimental: {
turbo: true,
}
};
module.exports = nextConfig;
// Using with npm scripts in package.json
{
"scripts": {
"dev": "next dev --turbo",
"build": "next build",
"start": "next start"
}
}
Enter fullscreen mode
Exit fullscreen mode
Built-in CSS and Sass support: Support for any CSS-in-JS library.
// Using CSS Modules in Next.js
// Path: components/Button.module.css
.button {
background: blue;
color: white;
padding: 8px 16px;
border-radius: 4px;
border: none;
cursor: pointer;
}
.button:hover {
background: darkblue;
}
// components/Button.js
import styles from './Button.module.css';
export default function Button({ children, onClick }) {
return (
{children}
);
}
// Global CSS in app/globals.css
body {
font-family: system-ui, sans-serif;
margin: 0;
padding: 0;
}
// Using in app/layout.js
import './globals.css';
export default function RootLayout({ children }) {
return (
{children}
);
}
Enter fullscreen mode
Exit fullscreen mode
Static Exports: Next.js allows you to export a fully static site from your app using the next export command.
// Path: next.config.js - Static export configuration
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
// Optional: Change the output directory
distDir: 'out',
// Optional: Add basePath for deployment to a subdirectory
basePath: '/docs'
};
module.exports = nextConfig;
// package.json
{
"scripts": {
"build": "next build",
"export": "next export" // For older Next.js versions
}
}
Enter fullscreen mode
Exit fullscreen mode
Advanced Server Actions: Next.js 14 introduces server actions for handling data mutations, simplifying backend logic without requiring separate API routes.
// Path: app/actions.js - Server Actions
'use server';
import { cookies } from 'next/headers';
import { revalidatePath } from 'next/cache';
import { db } from '@/lib/db';
export async function addToCart(formData) {
const productId = formData.get('productId');
const quantity = parseInt(formData.get('quantity') || '1');
// Get user from cookie
const userId = cookies().get('userId')?.value;
if (!userId) {
throw new Error('User not authenticated');
}
try {
await db.cart.upsert({
where: {
userId_productId: {
userId,
productId
}
},
update: {
quantity: { increment: quantity }
},
create: {
userId,
productId,
quantity
}
});
// Revalidate cart page
revalidatePath('/cart');
return { success: true };
} catch (error) {
return { success: false, error: error.message };
}
}
// app/products/[id]/page.js
import { addToCart } from '@/app/actions';
export default function ProductPage({ params }) {
// ...product details
return (
{/* ... */}
Add to Cart
);
}
Enter fullscreen mode
Exit fullscreen mode
Enhanced Caching: Improved caching mechanisms, including stale-while-revalidate (SWR), ensure faster content delivery and better user experiences.
// Using SWR for client-side data fetching
'use client';
import useSWR from 'swr';
// Reusable fetcher function
const fetcher = (...args) => fetch(...args).then(res => res.json());
export default function ProductList() {
const { data, error, isLoading } = useSWR('/api/products', fetcher, {
// Revalidate every 10 seconds
refreshInterval: 10000,
// Keep data even when fetching fails
revalidateOnError: false
});
if (isLoading) return Loading products...;
if (error) return Error loading products;
return (
Products
{data.map(product => (
{product.name}
))}
);
}
Enter fullscreen mode
Exit fullscreen mode
Hydration
Hydration is a client-side JavaScript technique for converting a static HTML page into a dynamic page. This provides a pleasant user experience by displaying a rendered component on the page but with attached event handlers. Hydration occurs before user interaction on static pages. The user experience suffers as a result.
Astro
Astro handles hydration through a method known as partial hydration. This approach loads individual components only when needed, leaving the rest of the page as static HTML. The island architecture is central to this process, as it ensures that only the necessary JavaScript is loaded, improving performance.
---
// Path: src/pages/hydration-example.astro
import StaticComponent from '../components/StaticComponent.astro';
import InteractiveCounter from '../components/InteractiveCounter.jsx';
import LazyLoadedComponent from '../components/LazyLoadedComponent.jsx';
import HeavyComponent from '../components/HeavyComponent.jsx';
---
Hydration Example
This only hydrates on mobile devices
This renders only on the client
Enter fullscreen mode
Exit fullscreen mode
In most cases, Astro websites load significantly faster than Next.js websites because Astro automatically strips unnecessary JavaScript and hydrates only the components that require interactivity.
By default, Astro delivers static HTML with minimal JavaScript, resulting in faster page loads and better performance for content-heavy sites.
Next.js
Next.js has evolved its hydration strategy with the introduction of React Server Components (RSCs) and Selective Hydration in Next.js 14. While it traditionally required full-page hydration, it now supports granular hydration for interactive components, reducing the amount of JavaScript sent to the client.
// Path: app/page.js - Server Component
// This doesn't require client-side JS
export default function HomePage() {
return (
Welcome to our site
This server component requires no client-side JavaScript
{/* Client components are selectively hydrated */}
);
}
// components/ClientSideInteractive.js
'use client'; // Mark as client component
import { useState } from 'react';
export default function ClientSideInteractive() {
// Client-side state and interactivity
const [count, setCount] = useState(0);
return (
This component is hydrated with JavaScript
Count: {count}
setCount(count + 1)}>
Increment
);
}
Enter fullscreen mode
Exit fullscreen mode
Next.js allows developers to hydrate only the interactive parts of a page, improving performance for static-heavy content.
Next.js continues to support zero-JavaScript pages through Static Site Generation (SSG) and Incremental Static Regeneration (ISR).
Unlike Astro’s island architecture, which hydrates individual components by default, Next.js still prioritizes full-page hydration but offers selective hydration as an experimental feature for optimization.
Remix
Remix does not support partial hydration. There are assumptions that Remix will function with the new React 19 suspense features, but Remix does not allow partial hydration.
// Path: app/entry.client.jsx - Client-side hydration in Remix
import { RemixBrowser } from '@remix-run/react';
import { startTransition, StrictMode } from 'react';
import { hydrateRoot } from 'react-dom/client';
// The entire app is hydrated at once
startTransition(() => {
hydrateRoot(
document,
);
});
Enter fullscreen mode
Exit fullscreen mode
Loading Speed
The loading speed plays an important role in web application, because it directly affects user experience, SEO performance and system performance. The loading speed optimization techniques of Astro, Remix and Next.js depend on their specific architectural methods and built-in features. Let’s take a look at how these frameworks handle performance and what makes them fast.
Astro
Astro is fast, basically designed for speed. The island architecture strategy aids in SEO because it ranks highly on on-site search engines. It offers a fantastic user experience and has less boilerplate code. It supports most CSS libraries and frameworks and provides a great base for style support.
// Path: astro.config.mjs - Performance optimizations
import { defineConfig } from 'astro/config';
import image from '@astrojs/image';
import compress from 'astro-compress';
export default defineConfig({
// Image optimization
integrations: [
image({
serviceEntryPoint: '@astrojs/image/sharp'
}),
// Compress HTML, CSS, and JavaScript
compress()
],
// Enable view transitions for smooth navigation
experimental: {
viewTransitions: true
},
// CSS optimizations
vite: {
build: {cssCodeSplit: true,
cssMinify: true,
}
}
});
Enter fullscreen mode
Exit fullscreen mode
Remix
Remix claims that data retrieval is sped up by loading data in parallel on the server. Remix can prerender pages on the server because it supports server-side rendering. In contrast to Remix, Astro provides a statically-bundled HTML file with minimal to no JavaScript.
Why the Remix rewrite is fast?
Instead of caching documents with SSG or SWR, this version caches data at the edge in Redis.
It runs the application at the edge too with Fly.io.
Quick image optimization Resource Route that writes to a persistent volume.
It’s its own CDN. This might have been difficult to build a few years ago, but the server landscape has changed significantly in the past few years and is only getting better.
// Path: remix.config.js - Performance configuration
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
// Deploy to edge runtime
serverBuildTarget: "vercel",
server: process.env.NODE_ENV === "development" ? undefined : "./server.js",
ignoredRouteFiles: ["**/.*"],
// Optimize JS output
future: {
v2_routeConvention: true,
v2_meta: true,
v2_errorBoundary: true,
v2_normalizeFormMethod: true,
},
// Caching strategy
serverDependenciesToBundle: "all",
// Custom Resource Routes for optimized assets
routes: function(defineRoutes) {
return defineRoutes((route) => {
route(
"/resources/image/:width/:height/:src",
"routes/resources/image.tsx"
);
});
}
};
// routes/resources/image.tsx - Image optimization route
import { LoaderFunction } from "@remix-run/node";
import { optimizeImage } from "~/utils/images.server";
export const loader: LoaderFunction = async ({ params, request }) => {
const { width, height, src } = params;
const format = new URL(request.url).searchParams.get("format") || "webp";
try {
const { buffer, contentType } = await optimizeImage({
src: src as string,
width: parseInt(width as string),
height: parseInt(height as string),
format,
});
return new Response(buffer, {
headers: {
"Content-Type": contentType,
"Cache-Control": "public, max-age=31536000, immutable",
},
});
} catch (error) {
return new Response("Image optimization failed", { status: 500 });
}
};
Enter fullscreen mode
Exit fullscreen mode
Why the Remix port is fast?
Remix now supports Static Site Generation (SSG), allowing developers to pre-render pages at build time.
The result is the same: a static document at the edge (even on the same CDN, Vercel’s). The difference is how the documents get there. Instead of fetching all the data and rendering the pages to static documents at build/deploy time, the cache is primed when you get traffic.
Documents are served from the cache and revalidated in the background for the next visitor.
// Parallel data fetching for improved performance
// Path: app/routes/dashboard.tsx
import { json } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { getUser, getStats, getActivities, getNotifications } from '~/models/dashboard.server';
export async function loader({ request }) {
const userId = await getUserId(request);
// Fetch all data in parallel for improved performance
const [user, stats, activities, notifications] = await Promise.all([
getUser(userId),
getStats(userId),
getActivities(userId),
getNotifications(userId)
]);
return json({
user,
stats,
activities,
notifications
});
}
export default function Dashboard() {
const { user, stats, activities, notifications } = useLoaderData();
// Render dashboard UI with fetched data...
}
Enter fullscreen mode
Exit fullscreen mode
Next.js
Next.js boasts of its server-side rendering and static builds features. Next.js also includes several pre-built techniques for data retrieval.
Why Next.js is fast?
The homepage uses Static Site Generation (SSG) with getStaticProps.
At build time, Next.js pulls data from Shopify, renders a page to an HTML file, and puts it in the public directory.
When the site is deployed, the static file is served at the edge (out of Vercel’s CDN) instead of hitting an origin server at a single location.
When a request comes in, the CDN serves the file.
Data loading and rendering have already been done ahead of time, so the visitor doesn’t pay the download + render cost.
The CDN is distributed globally, close to users (this is “the edge”), so requests for statically generated documents don’t have to travel to a single origin server.
Next.js now supports React Server Components (RSCs) and Selective Hydration, reducing the amount of JavaScript sent to the client and improving performance for dynamic content.
// Path: pages/index.js - Static Site Generation
export default function HomePage({ products, categories }) {
return (
Welcome to our store
{products.map(product => (
))}
);
}
// This runs at build time in production
export async function getStaticProps() {
// Fetch data from CMS, database, or API
const products = await fetchFeaturedProducts();
const categories = await fetchCategories();
return {
props: {
products,
categories
},
// Re-generate at most once per hour
revalidate: 3600
};
}
// Incremental Static Regeneration example
// pages/products/[id].js
export default function Product({ product }) {
// Render product details...
}
export async function getStaticPaths() {
// Pre-render only the most popular products
const popularProducts = await fetchPopularProducts();
return {
paths: popularProducts.map(product => ({
params: { id: product.id.toString() }
})),
// Enable ISR for products not generated at build time
fallback: 'blocking'
};
}
export async function getStaticProps({ params }) {
const product = await fetchProduct(params.id);
return {
props: { product },
revalidate: 60 // Update every minute if requested
};
}
Enter fullscreen mode
Exit fullscreen mode
SSR
Server-side rendering (SSR) refers to the process of pre-rendering client-side single-page applications on the server and then sending a fully rendered page on user request. Server-side rendering is essential because server-side rendered applications are SEO-friendly and fast. Apps that support server-side rendering are usually due to their reduced page load time.Astro, Remix, and Next.js offer server-side rendering (SSR) to generate the markup and content of our pages from the web server before sending it to the client.
// Astro SSR configuration
// Path: astro.config.mjs
import { defineConfig } from 'astro/config';
import nodejs from '@astrojs/node';
export default defineConfig({
output: 'server',
adapter: nodejs({
mode: 'standalone'
})
});
// Next.js SSR example
// pages/products/[id].js
export default function Product({ product }) {
return (
{product.name}
{product.description}
${product.price}
);
}
export async function getServerSideProps({ params, req, res }) {
// This runs on every request
const product = await fetchProduct(params.id);
// Set cache headers
res.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
);
return {
props: { product }
};
}
// Remix SSR example
// app/routes/products.$id.jsx
import { json } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
export async function loader({ params, request }) {
const product = await fetchProduct(params.id);
return json(
{ product },
{
headers: {
'Cache-Control': 'max-age=300, s-maxage=3600'
}
}
);
}
export default function Product() {
const { product } = useLoaderData();
return (
{product.name}
{product.description}
${product.price}
);
}
Enter fullscreen mode
Exit fullscreen mode
Ease Of Use
Next.js, Astro, and Remix have a short learning curve. Because they are all based on React, you only need a basic understanding of React to set up Next.js, Astro, and Remix. They all feature developer-friendly documentation, making them simple to use and configure.Next includes the create-next-app CLI command for quickly launching a Next.js application. For bootstrapping an Astro application, use the create astro@latest command, whereas Remix uses the create-remix@latest command for Remix apps.
# Create a new Next.js app
npx create-next-app@latest my-next-app
# Create a new Astro app
npm create astro@latest my-astro-app
# Create a new Remix app
npx create-remix@latest my-remix-app
Enter fullscreen mode
Exit fullscreen mode
Conclusion
We looked at Astro, a highly performant library for shipping no JavaScript code, Remix, a framework for handling client-side and server-side code, and Next.js, which includes data fetching methods such as ISR, CSR, SSG, and SSR.We looked at key features, loading speed, hydration, server-side rendering, and ease of use. This allows you to select the framework to utilize for your projects. It’s not about which framework is better but which solves your problem best.
// Framework selection helper
function recommendFramework(requirements) {
// Content-heavy site with minimal interactivity
if (requirements.contentFocused && requirements.minimalInteractivity) {
return "Astro";
}
// Full-stack application with forms and data mutations
if (requirements.formHandling && requirements.dataManagement) {
return "Remix";
}
// Enterprise application with complex requirements
if (requirements.enterprise && requirements.ecosystem) {
return "Next.js";
}
// General recommendation based on team experience
return requirements.teamExperience || "Next.js";
}
// Example usage
console.log(recommendFramework({
contentFocused: true,
minimalInteractivity: true,
teamExperience: "React"
})); // Output: "Astro"
Enter fullscreen mode
Exit fullscreen mode
If you would like to start building with these frameworks, check out these resources:
How to Build a Blog App with Remix and Strapi CMS
How to Create an SSG (Static Site Generation) Application with Strapi Webhooks and NextJs
Continue discussing this topic further or connect with more people using Strapi on our Discord community. It is a great place to share your thoughts, ask questions, and participate in live discussions.