🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@nldoc/api

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nldoc/api

API client and React hooks for NLdoc backend services.

latest
npmnpm
Version
2.0.1
Version published
Maintainers
3
Created
Source

@nldoc/api

API client and React hooks for NLdoc backend services.

Installation

npm install @nldoc/api

Usage

useApiClient

A React hook that creates an API client instance for communicating with NLdoc backend services.

import { useApiClient } from '@nldoc/api'

function MyComponent() {
  const apiClient = useApiClient('https://nldoc.nl/api')
  // or use a relative path
  const apiClient = useApiClient('/api')

  // apiClient will be null if no route is provided
  if (!apiClient) return null

  // Use the client...
}

Parameters:

  • apiRoute: string | null | undefined - The API route URL. Can be:
    • An absolute URL (e.g., 'https://nldoc.nl/api')
    • A relative path (e.g., '/api') - will be resolved relative to the current window location
    • null or undefined - returns null

Returns: APIClient | null

useConversion

A React hook for converting documents using NLdoc's Conversion API.

import { useConversion, ContentType } from '@nldoc/api'

function MyComponent() {
  const file = new Blob([JSON.stringify(myDocument)], { type: ContentType.Tiptap })
  const apiRoute = 'https://nldoc.nl/api'

  const conversion = useConversion(file, ContentType.HTML, apiRoute)

  // conversion.status can be: 'idle' | 'converting' | 'converted' | 'error'

  if (conversion.status === 'converted') {
    console.log(conversion.result) // The converted document
  }
}

Parameters:

  • file: Blob | null - The file to convert
  • to: string - The target content type (use ContentType constants)
  • apiRoute: string | null | undefined - The API route URL

Returns: UseConversion - An object containing the conversion status and result

Content Types

The package exports common content type constants:

import { ContentType } from '@nldoc/api'

ContentType.HTML      // 'text/html'
ContentType.Tiptap    // 'application/vnd.nldoc+json'
// ... and more

License

EUPL-1.2

FAQs

Package last updated on 22 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts