Installation

Astro Typesafe Routes integrates seamlessly into your Astro project, offering automatic type safety for your routes. Ensure your project uses Astro version 5.0.0 or higher. Follow the steps below to set it up and enhance your development experience.


Prerequisites

  1. Astro ^5.0.0 is required
  2. Install Typescript and Astro Check
npm i -D typescript @astrojs/check
  1. Add astro check command to build script in package.json
{
  "scripts": {
    "build": "astro check && astro build"
  }
}

Automatic Installation

  1. Add integration:
npx astro add astro-typesafe-routes
  1. Start the Astro development server if it’s not already running to run type generation:
npm run dev

Manual Installation

If automatic installation didn’t work, follow these steps:

  1. Install package:
npm install astro-typesafe-routes
  1. Add integration to astro.config.mjs:
import { defineConfig } from "astro/config";
import astroTypesafeRoutes from "astro-typesafe-routes";

export default defineConfig({
  integrations: [astroTypesafeRoutes()],
});
  1. Start the Astro development server if it’s not already running to run code generation:
npm run dev