npm package: @oxmo88/next-wordpress-api
Description: Production-ready WordPress REST API client for Next.js with advanced caching, retry logic, and multi-locale support
Author: Your Name
Latest version: 1.1.0

# WordPress API Client for Next.js

A powerful tool that connects your Next.js application to WordPress, making it easy to fetch and display your WordPress content with optimal performance.

---

## What Does This Package Do?

This package helps you build modern, fast websites using WordPress as your content management system and Next.js as your frontend framework. It handles all the complexity of connecting to WordPress, retrieving your content, and making sure everything runs smoothly and quickly.

Think of it as a smart bridge between WordPress (where you create and manage content) and Next.js (where you display that content beautifully).

---

## Why Use This Package?

### **Faster Loading Times**
WordPress normally sends way more data than you need. This package automatically optimizes what gets sent, making your pages load up to **4 times faster** and using **85% less bandwidth**.

### **Works Reliably**
Internet connections aren't perfect. This package automatically retries failed requests and handles errors gracefully, so your website stays reliable even when things go wrong.

### **Built-in Caching**
Content is automatically cached (stored temporarily) so repeat visits are lightning fast. The package is smart about when to refresh content and when to use the cached version.

### **Multi-Language Support**
If your WordPress site supports multiple languages (using Polylang or WPML), this package makes it seamless to fetch content in any language.

### **Simple to Use**
You don't need to be an expert in APIs or WordPress. The package provides simple, straightforward methods to get posts, pages, categories, media, and more.

---

## Key Features at a Glance

✅ **Optimized Performance** - Automatically reduces data transfer by up to 85%
✅ **Smart Caching** - Built-in caching keeps your site fast
✅ **Automatic Retries** - Handles network issues automatically
✅ **Multi-Language Ready** - Easy support for multilingual sites
✅ **Type-Safe** - Full TypeScript support prevents errors
✅ **Next.js Optimized** - Works perfectly with Next.js App Router and Server Components
✅ **Production Ready** - Built for real-world use with large-scale websites

---

## Quick Installation

```bash
npm install @oxmo88/next-wordpress-api
```

---

## Simple Example

```typescript
import { WordPressClient } from '@oxmo88/next-wordpress-api'

// Connect to your WordPress site
const wp = new WordPressClient({
  baseUrl: 'https://your-wordpress-site.com'
})

// Get your latest blog posts
const posts = await wp.posts.list({ per_page: 10 })

// Get a specific page
const aboutPage = await wp.pages.getBySlug('about')

// Get categories
const categories = await wp.categories.list()
```

That's it! You're now pulling content from WordPress into your Next.js application.

---

## What Can You Fetch?

The package gives you easy access to all your WordPress content:

- **Posts** - Blog articles, news items, or any custom post type
- **Pages** - Static pages like About, Contact, etc.
- **Categories & Tags** - Organize and filter your content
- **Media** - Images, videos, and other media files
- **Comments** - User comments on posts
- **Users** - Author information

---

## How It Improves Performance

### The Problem
By default, WordPress sends **huge amounts of data** - about 50KB per blog post, even when you only need the title and excerpt for a list. For a homepage showing 20 posts, that's over 1MB of unnecessary data!

### The Solution
This package has smart "modes" that automatically fetch only what you need:

- **List View** (homepage, archives): Only gets titles, excerpts, and images → 85% less data
- **Detail View** (full article): Gets complete content with everything you need
- **Custom**: You choose exactly what fields to fetch

**Result**: Your pages load 4x faster and use much less bandwidth.

---

## Multilingual Support Made Easy

If you run a multilingual WordPress site, this package handles language switching seamlessly:

```typescript
// Get posts in English
const englishPosts = await wp.posts.list({ locale: 'en' })

// Get posts in French
const frenchPosts = await wp.posts.list({ locale: 'fr' })

// Get posts in Spanish
const spanishPosts = await wp.posts.list({ locale: 'es' })
```

Works automatically with Polylang and WPML plugins.

---

## Built for Next.js

This package is specifically designed to work perfectly with Next.js features:

- **Server Components** - Fetch content directly in your components
- **Static Site Generation (SSG)** - Pre-build pages at build time
- **Incremental Static Regeneration (ISR)** - Update static pages without rebuilding
- **API Routes** - Create custom API endpoints

---

## Who Should Use This?

- **Developers** building modern websites with WordPress and Next.js
- **Agencies** creating client websites that need performance and reliability
- **Content Creators** who want to use WordPress for content but need a faster frontend
- **Businesses** running multilingual websites
- **Anyone** wanting to combine WordPress's excellent content management with Next.js's speed and modern features

---

## System Requirements

- Next.js 13 or higher
- WordPress 6.0 or higher with REST API enabled (enabled by default)
- Node.js 18 or higher

---

## Get Started

Install the package and start building:

```bash
npm install @oxmo88/next-wordpress-api
```

For detailed documentation and advanced features, visit the [full documentation](#).

---

## License

MIT

---

**Built for developers who want the content power of WordPress with the performance of Next.js.**