Search by Algolia

Sorry, there is no results for this query

Bringing the Missing Frontend Search Block to the Laravel Vue.js Community

Aug 23rd 2017 engineering

Bringing the Missing Frontend Search Block to the Laravel Vue.js Community

Last year, Taylor Otwell, the maker of Laravel, decided to create an official Laravel package named Scout. The package allows Laravel users to add full-text search on top of their existing database without much effort.

I was very happy to notice that Taylor identified search as being something complex that developers would need help with. I was even more excited by the fact that he chose Algolia as the default engine.

Vue.js and Laravel === the perfect mix

In Laravel 5.3, Taylor Otwell chose to power the frontend with the Vue.js framework. Every Laravel app since 5.3 now ships with a ready-to-use Vue.js skeleton.

Because Taylor made that move, Vue.js instantly got my attention. My thought process was that if Taylor chose to ship his backend framework with Vue.js in the frontend, it probably means that Vue.js shares some core values with Laravel. Vue.js is easy to learn, it thrives at empowering developers to add logic to the frontend, and it advances forward quickly.

I remember this one time I opened a very naive PR to adapt the lifecycle of the components in core of Vue.js. Evan You, maker of Vue.js immediately picked it up:

Laravel and Vue.js are each made and driven by a single person. While some might argue this is a disadvantage, I see it as an opportunity to have opinionated people be more innovative and also be more reactive. This is even more true when those people have a very clear idea of where they are going and manage to stay open to the community.

Building a UI components library for Vue.js

Building search on the frontend has the advantage of offloading all search related operations from your Laravel app. Thanks to the Laravel Scout package, little setup is required to send your data to Algolia. I wanted to help developers also benefit from great search experience — this time, on the frontend.

We wanted to create a library that would embody the same principles as Laravel: something users could easily install in existing applications and shape for their own need.

Vue.js offers a very convenient way of creating components in single files. This approach is very readable and makes it easy to reason about the search experience you are building.

So, we ended up bootstrapping a bunch of components that can just be dropped into your Vue.js skeleton. Components will then handle all the logic consisting of listening for user changes and asking Algolia for the new results:

All you need in order to use the above syntax in your own Vue.js application is to actually register the plugin:

How I challenged Vue InstantSearch

After sharing my excitement about this new library, other engineers at Algolia wanted to try it out. They were intrigued by both Vue.js and Vue InstantSearch, so we started writing some documentation in order for them to try out my work.

To allow users to experiment with the library, I created a step-by-step getting started guide. When you reach the bottom of the guide, you have a working instant search experience.

We were really happy when testers told us they managed to get their search up and running in a couple of minutes, even insisting on the fact that they knew nothing about Vue.js previously. At the same time, I have to say that the feedback was largely due to the benefits of Vue.js framework itself, since Vue InstantSearch leverages its available features.

Because of the excitement around the library, and because we had already been invited to speak at the annual Laracon US event, we thought giving a preview of the library at the conference would be a good idea. We didn’t expect much other than to share the idea with the community and get some feedback in advance of the full release.

Maxime Locqueville gave a live coding talk where he explained how to index data with Laravel Scout, and how to leverage Vue InstantSearch. By the end of the 30 minute talk, he had illustrated how to build a fully blown instant-search experience with customized relevance. It was the first time Vue InstantSearch was mentioned in the wild, and then came this:

Laracasts is the place where Jeffrey Way explains Laravel A-Z. I was really honored that Laracasts didn’t just talk about us, but were the first real Vue InstantSearch users.

To be honest, I was a bit scared that Jeffrey would find blocking issues with the state of the library at that time. He raised some small questions in his first recording which we quickly addressed, and I was also very glad he gave us some more feedback via direct message.

The Vue InstantSearch journey is just starting

Today we have over 100 users and about as much GitHub stars, but the project was still considered unreleased until today, because I wanted to make sure we had the right docs and enough feedback from testers.

This project has been so far the best pre-launch experience I’ve witnessed, largely thanks to  the communities it addresses. I’d also like to give a special mention to my colleague Haroen who has been challenging ideas and reviewing a fair amount of everything that is in Vue InstantSearch. The project would not have been in the current stage without him.

V1 is, of course, just the beginning. Vue.js & Laravel have a strong future and we are excited to be a small part of it. Now, what can we do better? How can we help your use case? We look forward to your feedback: @algolia & @rayrutjes.

About the author
Raymond Rutjes

Software Engineer


14-day free trial

Create a full-featured search experience in no time.

Get started
14-day free trial

Recommended Articles

Powered byAlgolia Algolia Recommend

Deep Diving into Vue InstantSearch Version 2

Haroen Viaene

JavaScript Library Developer

Announcing instantsearch.js: Everything you need for great search in one library

Alexandre Stanislawski

Redesigning Our Docs – Part 5 – Building an Interactive InstantSearch Showcase

Sarah Dayan

Staff Software Engineer