Directus Integration with Frontend (React/Vue/Next.js)

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Directus Integration with Frontend (React/Vue/Next.js)
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Integrating Directus with Frontend (React/Next.js)

Directus provides an official TypeScript SDK with typed requests. For Next.js App Router — Server Components for server requests and React hooks for client interaction.

SDK Installation

npm install @directus/sdk

Client Setup

// lib/directus.ts
import { createDirectus, rest, staticToken, readItems, readItem } from '@directus/sdk'

interface Article {
  id: number
  title: string
  slug: string
  content: string
  status: 'draft' | 'published' | 'archived'
  date_published: string
}

interface DirectusSchema {
  articles: Article[]
  categories: { id: number; name: string }[]
}

const directus = createDirectus<DirectusSchema>(process.env.DIRECTUS_URL!)
  .with(staticToken(process.env.DIRECTUS_STATIC_TOKEN!))
  .with(rest())

export { directus }

Server Components (Next.js App Router)

// app/articles/page.tsx
import { directus } from '@/lib/directus'
import { readItems } from '@directus/sdk'

export default async function ArticlesPage({
  searchParams,
}: {
  searchParams: { page?: string }
}) {
  const page = Number(searchParams.page) || 1
  const limit = 12

  const articles = await directus.request(
    readItems('articles', {
      fields: ['id', 'title', 'slug', 'excerpt', 'date_published'],
      filter: { status: { _eq: 'published' } },
      sort: ['-date_published'],
      limit,
      offset: (page - 1) * limit,
    })
  )

  return <ArticleGrid articles={articles} />
}

Webhooks for On-demand Revalidation

// app/api/revalidate/route.ts
import { revalidateTag, revalidatePath } from 'next/cache'

export async function POST(req: Request) {
  const secret = req.headers.get('x-webhook-secret')
  if (secret !== process.env.DIRECTUS_WEBHOOK_SECRET) {
    return Response.json({ error: 'Unauthorized' }, { status: 401 })
  }

  const { collection, keys } = await req.json()

  revalidateTag(collection)

  if (collection === 'articles' && keys[0]) {
    revalidatePath(`/articles/${keys[0]}`)
  }

  return Response.json({ revalidated: true })
}

Timeline

Directus integration with Next.js (SDK, ISR, webhooks, TypeScript types) — 2–3 days.