This integration demonstrates how to combine the power of Algolia's search capabilities with Makeswift's visual page building platform. Build visually editable websites with fast, intelligent search powered by Algolia's crawler that automatically indexes your Makeswift pages.
- Node.js 20.x or later
- Makeswift account (for visual page building) Sign up for free
- Algolia account (for search indexing) Sign up for free
- Basic familiarity with Next.js App Router
This guide assumes that you're familiar with Makeswift and setting up a custom host. Read here to learn more: https://docs.makeswift.com/developer/app-router/installation
algolia-demo/
├── app/ # Next.js App Router pages
│ ├── [[...path]]/ # Dynamic Makeswift routes
│ ├── api/makeswift/ # Makeswift API routes
│ ├── layout.tsx # Root layout with Makeswift provider
│ ├── globals.css # Global styles
│ └── sitemap.ts # Auto-generated sitemap for SEO
├── components/ # Makeswift components
│ ├── AlgoliaSearch/ # Search component integration
│ │ ├── client.tsx # Main search UI component
│ │ └── register.ts # Makeswift component registration
│ └── Navigation/ # Navigation component
├── lib/ # Utility functions and configs
│ ├── algolia/ # Algolia client configuration
│ ├── makeswift/ # Makeswift runtime & provider setup
│ └── utils.ts # Shared utilities
├── vibes/soul/ # Pre-built UI components
└── env.ts # Environment variable validation
npx makeswift@latest init --example=algolia-demo
Create a .env.local
file and add your credentials:
MAKESWIFT_SITE_API_KEY=your_makeswift_api_key
NEXT_PUBLIC_ALGOLIA_APP_ID=your_algolia_app_id
NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY=your_algolia_search_api_key
NEXT_PUBLIC_ALGOLIA_INDEX_NAME=your_algolia_index_name
ALGOLIA_SITE_VERIFICATION=your_algolia_site_verification
Before setting up the crawler, you need to get your domain verification key from Algolia:
- Navigate to the Algolia Crawler Getting Started guide
- Follow the "Add domains" section to add your domain
- In the domain verification section, choose the Meta tag method
- Copy the verification code from the meta tag (the value after
algolia-site-verification
) - Add this code to your
.env.local
file asALGOLIA_SITE_VERIFICATION
The verification meta tag is already included in app/layout.tsx
:
export const metadata: Metadata = {
other: {
'algolia-site-verification': env.ALGOLIA_SITE_VERIFICATION,
},
}
- Deploy your site to your hosting platform (Vercel, Netlify, etc.)
- In your Makeswift dashboard, set your deployed domain as the custom host
- Create and publish some pages in Makeswift to have content for indexing
- Once your site is deployed with the verification meta tag, return to the Algolia Crawler dashboard
- Click Verify now next to your domain
- Algolia will confirm ownership by detecting the meta tag on your live site
After your domain is verified, you can create the crawler:
- In the Algolia Crawler dashboard, click "New Crawler"
- Enter your crawler configuration:
- Crawler name: A descriptive name
- App ID: Your Algolia application ID
- Start URL: Your domain's home page
- Crawler template: Select the default template
- Click Create to run the initial test crawl
The crawler will automatically extract:
- Page titles
- Meta descriptions
- Main content text
- Main image
- URLs
pnpm install
pnpm dev
Your site will be available at http://localhost:3000
.
This integration includes a powerful search component that you can add to any Makeswift page:
You can find the search component being used in the navigation bar, but you can also find it available in the component tray.
- In the Makeswift builder, open any page or create a new one
- In the builder's left sidebar, find the Algolia Search component and drag it onto your page
- Configure the component properties:
- Placeholder text: Customize the search input placeholder (default: "Search...")
- Initial results to show: Number of results displayed initially (default: 8)
- Results per pagination: Number of additional results to load when users click "Show more" (default: 8)
The Algolia Search component includes:
- Real-time search: Results update as users type (debounced for performance)
- Keyboard navigation: Arrow keys to navigate results, Enter to select
- Click outside to close: Intuitive UX for search results
- Pagination: "Show more" button to load additional results
- Typo tolerance: Algolia's built-in typo tolerance for better search experience
- Responsive design: Works on all device sizes
The integration automatically helps Algolia discover all your Makeswift pages through:
- Sitemap Generation: The
app/sitemap.ts
file automatically generates a sitemap containing all published Makeswift pages - Crawler Configuration: Point your Algolia crawler to your sitemap URL for automatic page discovery
- Continuous Updates: When you publish new pages in Makeswift, they're automatically added to the sitemap
- Page Publishing: When you publish a page in Makeswift, it becomes available at its URL
- Sitemap Update: The sitemap automatically includes the new page
- Crawler Detection: The Algolia crawler detects the sitemap changes (if configured)
- Content Extraction: The crawler visits the new page and extracts searchable content
- Index Update: The extracted content is added to your Algolia search index
The crawler automatically extracts:
- Page titles from
<title>
tags and<h1>
elements - Meta descriptions from
<meta name="description">
tags - Main content from page body, excluding navigation and footer
- Images from
<img>
tags and<meta property="og:image">
tags - URLs for result navigation
The search component is registered as a Makeswift component with configurable properties:
runtime.registerComponent(
lazy(() => import('./client')),
{
type: 'AlgoliaSearch',
label: 'Algolia Search',
props: {
className: Style(),
placeholder: TextInput({ label: 'Placeholder text', defaultValue: 'Search...' }),
maxResults: Number({ label: 'Initial results to show', defaultValue: 8, min: 1, max: 50 }),
paginationLimit: Number({
label: 'Results per pagination',
defaultValue: 8,
min: 1,
max: 20,
}),
},
}
)
This allows content creators to customize the search experience directly in the Makeswift builder.
Common issues and solutions:
- Check environment variables: Ensure all Algolia credentials are correctly set in
.env.local
- Verify API keys: Make sure you're using the search-only API key (not admin key) for client-side usage
- Check index name: Verify the index name matches between your environment variables and Algolia dashboard
- Crawler status: Check your crawler status in the Algolia dashboard
- Index population: Ensure the crawler has successfully populated the index
- Search attributes: Verify your pages contain the expected attributes (
title
,description
, etc.) - Publishing status: Make sure your Makeswift pages are published and accessible
- Sitemap accessibility: Verify your sitemap is accessible at
/sitemap.xml
- Page accessibility: Check that your pages are publicly accessible (not behind authentication)
- Crawler configuration: Verify start URLs and sitemap URLs in crawler settings