finom / vovk

RESTful RPC for Next.js - Transforms Next.js into a powerful REST API platform with RPC capabilities.

Home Page:https://vovk.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌻 Support Ukraine Now! 🇺🇦


vovk
REST for Next

Transforms Next.js into a powerful and extensible REST API platform.
Made with TypeScript, inspired by NestJS.

Website     Documentation     Interactive Examples     vovk-zod     vovk-hello-world     vovk-react-native-example

npm version  TypeScript  Build status


Example back-end Controller Class:

import { get, prefix } from 'vovk';

@prefix('hello')
export default class HelloController {
  /**
   * Return a greeting from 
   * GET /api/hello/greeting
   */
  @get('greeting')
  static getHello() {
    return { greeting: 'Hello world!' };
  }
}

Example component that uses the auto-generated client library:

'use client';
import { useState } from 'react';
import { HelloController } from 'vovk-client';
import type { VovkClientReturnType } from 'vovk';

export default function Example() {
  const [
    serverResponse, setServerResponse,
  ] = useState<VovkClientReturnType<typeof HelloController.getHello>>();

  return (
    <>
      <button
        onClick={async () => {
          setServerResponse(
            await HelloController.getHello()
          );
        }}
      >
        Get Greeting from Server
      </button>
      <div>{serverResponse?.greeting}</div>
    </>
  );
}

About

RESTful RPC for Next.js - Transforms Next.js into a powerful REST API platform with RPC capabilities.

https://vovk.dev

License:MIT License


Languages

Language:TypeScript 81.1%Language:JavaScript 18.6%Language:CSS 0.3%