Vue.js Generator

Bootstrap a Vue 3 application using create-vue:

npm init vue@latest -- --typescript --router --pinia --eslint-with-prettier my-app
cd my-app

Install the required dependencies:

npm install dayjs qs @types/qs

To generate all the code you need for a given resource run the following command:

npm init @api-platform/client src/ -- --generator vue --resource book

Replace the URL with the entrypoint of your Hydra-enabled API. You can also use an OpenAPI documentation with and -f openapi3.

Omit the resource flag to generate files for all resource types exposed by the API.

Note: Make sure to follow the result indications of the command to register the routes.

Replace the content of App.vue with the following code:

// src/App.vue
  <RouterView />

<script setup lang="ts">
import { RouterView } from "vue-router";

Optionally, install Tailwind to get an app that looks good:

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

Replace the content of tailwind.config.js by:

// tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
  theme: {
    extend: {},
  plugins: [],

Replace the content of src/assets/main.css by:

@tailwind base;
@tailwind components;
@tailwind utilities;

You can launch the server with:

npm run dev

Go to http://localhost:5173/books/ to start using your app.

Note: In order to Mercure to work with the demo, you have to use the port 3000.

What' new?

API platform conference 2022

Sep 15,16 2022: new edition of our conference dedicated to API Platform and its ecosystem!