{"id":45548,"library":"next-cache","title":"NextCache","description":"NextCache is a server-side rendering cache service designed for clustering and distributed applications. It provides a WebSocket-based client-server architecture for caching SSR data, with TTL support and async value resolution. Version 1.3.3 requires Node.js 10.15.3 and npm 6.4.1. Compared to other caching solutions, NextCache is specialized for SSR caching and uses WebSockets for real-time communication.","status":"active","version":"1.3.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install next-cache","lang":"bash","label":"npm"},{"cmd":"yarn add next-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add next-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"WebSockets library for client-server communication","package":"ws","optional":false}],"imports":[{"note":"This package is CommonJS-only; does not support ESM imports.","wrong":"import { Server } from 'next-cache';","symbol":"Server","correct":"const { Server } = require('next-cache');"},{"note":"Same as Server, CJS only.","wrong":"import { Client } from 'next-cache';","symbol":"Client","correct":"const { Client } = require('next-cache');"},{"note":"No default export; use namespace import.","wrong":"import NextCache from 'next-cache';","symbol":"default export","correct":"const NextCache = require('next-cache'); // then use NextCache.Server or NextCache.Client"}],"quickstart":{"code":"const { Server, Client } = require('next-cache');\n\n// Start server\nconst server = new Server({ port: 666 });\nserver.start();\n\n// Client usage\nconst client = new Client('ws://localhost:666');\nasync function main() {\n  await client.connect();\n  const data = await client.get('myKey', async () => {\n    // Simulate async data fetch\n    return await new Promise(resolve => {\n      setTimeout(() => {\n        resolve({ value: { hello: 'world' }, ttl: 3600 });\n      }, 1000);\n    });\n  });\n  console.log(data); // { hello: 'world' }\n}\nmain().catch(console.error);","lang":"javascript","description":"Demonstrates starting a NextCache server and using the client to fetch cached data with a TTL of 1 hour."},"warnings":[{"fix":"Upgrade Node.js to version 10.15.3+.","message":"Requires Node.js 10.15.3 or higher. Older Node versions are not supported.","severity":"breaking","affected_versions":"<10.15.3"},{"fix":"Consider migrating to an actively maintained caching solution like ioredis or lru-cache.","message":"Package has not been updated since 2019 and may have unpatched vulnerabilities in dependencies.","severity":"deprecated","affected_versions":"all"},{"fix":"Always await client.connect() before using client.get().","message":"WebSocket client must call connect() before any cache operations. Calling get() without connect will throw an error.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.3':39 '10.15.3':42 '6.4.1':45 'applic':16 'architectur':26 'async':35 'base':22 'cach':9,28,49,56 'client':24 'client-serv':23 'cluster':13 'communic':64 'compar':46 'data':30 'design':11 'distribut':15 'javascript':65 'nextcach':1,2,51 'node.js':41 'npm':44 'provid':18 'real':62 'real-tim':61 'render':8 'requir':40 'resolut':37 'server':6,25 'server-sid':5 'servic':10 'side':7 'solut':50 'special':53 'ssr':29,55 'support':33 'time':63 'ttl':32 'use':58 'valu':36 'version':38 'websocket':21,59 'websocket-bas':20","created_at":"2026-06-07T12:55:33.054389+00:00","updated_at":"2026-06-07T12:55:33.054389+00:00","problems":[{"fix":"Install 'ws' via npm install ws and ensure Node.js >= 10.15.3.","cause":"The 'ws' package may not be installed or the environment lacks WebSocket support (e.g., in older Node.js).","error":"ReferenceError: WebSocket is not defined"},{"fix":"Start the server first and verify the WebSocket URL (e.g., ws://localhost:666).","cause":"The NextCache server is not running or the client URL is incorrect.","error":"Error: connect ECONNREFUSED"},{"fix":"Ensure you create a new Client and await connect() after instantiation.","cause":"The client instance was not properly initialized or connect() was not called.","error":"TypeError: client.get is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"next-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}