npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

astro-laravel

v0.0.4

Published

Astro adapter to generate type safe blade templates.

Downloads

521

Readme

astro-laravel

Astro adapter for Laravel

astro-laravel lets you build Laravel Blade templates with Astro. Write .blade.php.astro files inside your Astro project and compile them directly into your Laravel application's resources/views directory.

With astro-laravel, you can build Laravel views using Astro's JSX-style component syntax while still rendering standard Blade templates.

Unlike solutions such as Inertia.js, the final application does not require a persistent Node.js runtime in production.

How It Works

During development:

  • Astro handles views compilation and HMR
  • Requests are proxied through Astro for seamless development experience

When building for production:

  • .blade.php.astro files are compiled into Blade templates
  • Static assets are emitted into Laravel's public/ directory
  • No Node.js runtime is required in production

Laravel continues to handle:

  • Routing
  • Controllers
  • Middleware
  • Authentication
  • Server-side rendering

Installation

Prerequisites

  • A working local laravel app (e.g., running at http://localhost:8001)

Steps

  1. Create a new Astro project

    npm create astro@latest
  2. Add the astro-laravel adapter

    npx astro add astro-laravel
  3. Update your astro.config.mjs

    // @ts-check
    import { defineConfig, passthroughImageService } from "astro/config";
    import laravel from "astro-laravel";
    
    // https://astro.build/config
    export default defineConfig({
      server: {
        host: "127.0.0.1",
      },
      adapter: laravel({
        installationDir: "../laravel-path/", // Laravel installation path
        devProxyTarget: "http://localhost:8001", // Your local laravel server URL
    
        // Optional
        viewsDirPath: "./resources/views/astro/",
        publicDirPath: "./public/",
      }),
      image: {
        service: passthroughImageService(),
      },
    });
  4. Create a layout (e.g., src/layouts/Layout.astro)

    <!doctype html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="x-ua-compatible" content="ie=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
      </head>
      <body>
        <main>
          <slot />
        </main>
      </body>
    </html>
  5. Add a template view (e.g., src/pages/welcome.blade.php.astro)

    ---
    import Layout from "../layouts/Layout.astro";
    ---
    
    <Layout>
      <h1>
        Hello {'{{ $name }}'}
      </h1>
    </Layout>
  6. Start the dev server

    npm run dev
  7. Use welcome.blade.php like any standard Laravel view:

  <?php

  use Illuminate\Support\Facades\Route;

  Route::get('/', function () {
      return view('astro/welcome', ['name' => 'User Name']);
  });

Configuration Options

| Option | Description | Default | |-------------------|---------------------------------------------------------------------------------|--------------------------------------------| | installationDir | Path to your Laravel application | Required | | devProxyTarget | Local Laravel server URL | Required | | viewsDirPath | Directory where compiled Blade templates are written and replaced during builds | {installationDir}/resources/views/astro/ | | publicDirPath | Output directory for generated assets | {installationDir}/public/ |

Build for Production

Generate production-ready Blade views and assets:

npm run build

Generated output:

  • Blade views → resources/views/astro/
  • Static assets → public/

Both directories can be customized using viewsDirPath and publicDirPath.

View Directory

By default, compiled Blade templates are generated into resources/views/astro/, The /astro suffix is intentional.

During builds, the adapter replaces the contents of the configured viewsDirPath directory with freshly compiled views. Using a dedicated subdirectory helps avoid accidentally overwriting existing Laravel Blade templates.

If you change viewsDirPath, it is recommended to use a dedicated directory exclusively managed by astro-laravel.

Public Assets

Astro's local public/ directory is ignored by this adapter.

To serve static assets such as images, fonts, or downloadable files, place them inside your Laravel application's public/ directory instead.

Example:

laravel/
└── public/
    ├── images/
    ├── fonts/
    └── favicon.ico

Then reference them normally inside your Astro templates:

<img src="/images/logo.png" alt="Logo" />

This ensures assets are served correctly by Laravel in both development and production environments.

Example Project Structure

my-project/
├── astro/
│   ├── src/
│   │   ├── layouts/
│   │   │   └── Layout.astro
│   │   └── pages/
│   │       └── welcome.blade.php.astro
│   └── astro.config.mjs
│
└── laravel/
    ├── resources/
    │   └── views/
    └── public/

Dynamic Blade Components with Astro Stencil

For type-safe dynamic Blade rendering, you can combine this adapter with astro-stencil.

astro-stencil allows you to define strongly typed template inputs and safely render dynamic Laravel data inside Astro components.