Empower and Enhance Your VitePress Blog with a Laravel API

Transform your VitePress blog into a dynamic platform with an API

Hello! 👋

After building our VitePress blog, we are ready to make it more dynamic with a Laravel API.

In the previous series, we explored VitePress from the initial project setup to deployment on Cloudflare Pages. We built a functional, automated blog with SEO metadata, Open Graph images, and a GitHub projects page. The blog handled everything at build time, so publishing content was the only task left.

Create a Blog with VitePress and Vue.js from Scratch

This series introduces back-end development by creating a Laravel API that gives our blog a few interactive features.

Until now, our blog has been mostly static. Content was generated at build time, with a small amount of data loaded dynamically, and the resulting HTML files were distributed through a CDN. By adding a Laravel API, we will let readers interact with the blog through features such as post reactions and comments.

Although the focus is on the back end, we will also integrate the API into our VitePress blog. We will use Vue.js and Pinia Colada as our data-fetching framework. VitePress is a Vue.js application, so we can extend it with the components we need.

The examples are designed to be easy to follow. Unnecessary complexity and over-engineering are neither desirable nor necessary here. We will focus on simplicity, clarity, and efficiency.

Throughout the series, we will build a Laravel API and integrate it with our VitePress blog. We will cover:

  • Setting up the Laravel project: Create a new Laravel project and become familiar with its structure.
  • Improving the development workflow: Configure Pint, Rector, Larastan, and Pest for formatting, refactoring, static analysis, and testing.
  • Adding social authentication: Let users sign in with GitHub through Laravel Socialite.
  • Connecting the applications: Configure Sanctum, CORS, CSRF protection, and the first requests between the VitePress frontend and the Laravel API.
  • Managing authentication state: Use Pinia Colada to retrieve the current user and log out with an optimistic update.
  • Building the comment API: Create the models, relationships, endpoints, validation, authorization, and tests for comments.
  • Keeping the backend in sync: Generate post metadata from VitePress and synchronize it with the Laravel database.
  • Building the comment interface: Fetch, create, edit, and delete comments from the VitePress frontend.

By the end of the series, you will have a blog backed by a Laravel API. Readers will be able to sign in with GitHub and leave comments, and the architecture will be ready for additional interactive features.

Testing is part of the development process and will be included at each stage, so it does not need a dedicated article.

If you have questions, feedback, or suggestions, feel free to share them in the comments. Your input helps improve the series.

Note

This series assumes prior knowledge of TypeScript, Vue.js, and Laravel. If you are unfamiliar with any of these technologies, review the Create a Blog with VitePress and Vue.js from Scratch first.

If you enjoy my content, please consider supporting my work!

All Articles

  1. 1. Setting Up Your Laravel Project Structure and Essentials

    A comprehensive guide to setting up your Laravel project and understanding its structure for a better development experience.

  2. 2. Pint, Rector, Larastan, and Pest: Essentials for Success

    Explore the four indispensable tools for maintaining code quality and consistency in Laravel projects: Pint, Rector, Larastan, and Pest.

  3. 3. Effortless Social Authentication with Laravel Socialite

    Add GitHub authentication to Laravel with Socialite, OAuth callbacks, database synchronization, secure sessions, and test-first development.

  4. 4. Building a Simple Comment System for User Engagement

    Build a Laravel comment API with models, migrations, resources, policies, form requests, controllers, routes, and comprehensive tests.

  5. 5. Automating Your Backend to Stay in Sync Effortlessly

    Generate frontend metadata with VitePress, synchronize posts with Laravel, and keep the backend database aligned automatically.

  6. 6. Bridging the Gap: Connecting Your Frontend and Backend

    Connect a VitePress frontend to a Laravel API with Sanctum, CORS, CSRF protection, shared credentials, and a reusable API client.

  7. 7. Streamlining User Authentication from Frontend to Backend

    Connect frontend authentication to Laravel with a current-user query, GitHub logout flow, Pinia Colada caching, and optimistic state updates.

  8. 8. Simplifying Comment Querying and Editing with Pinia Colada

    Build the VitePress comment interface with Pinia Colada queries, mutations, optimistic updates, reusable Vue components, and permissions.

Meet the Instructor

PP

My name is Estéban Soubiran.

I'm a web engineer and technical writer who loves sharing with others.

I create this series because I love VitePress and Laravel. I truly believe that combining the two results in a simple yet powerful solution for creating a blog. I want to empower developers to enhance their VitePress blogs with a Laravel API to create advanced features.

If you want to get in touch, you can always find me on Bluesky, X, and LinkedIn or shout out a mail to esteban@soubiran.dev.

Reactions

Discussions

Add a Comment

You need to be logged in to access this feature.

Support my work
Follow me on