Skip to content

Demo repository for Next.js + React Server Components + @strya/opa

License

Notifications You must be signed in to change notification settings

StyraInc/next-react-server-components-opa

 
 

Repository files navigation

Next.js App Router + React Server Components

Introduction

This is a demo app of the Hacker News website clone, which shows Next.js App Router with support for React Server Components combined with server-side OPA evaluation via @styra/opa.

Running Locally

First start OPA with the included policies:

opa run -ldebug -w -s policies

When using Enterprise OPA, the @styra/opa SDK as used here will benefit from its Batch API.

Then spin up the Next.js dev setup:

  1. pnpm install
  2. pnpm dev

Go to localhost:3000.

Click on any story's comments. You'll find them all comments by users with karma less than 1000 (indicated in parenthesis after their name) collapsed. This happend on the server: it used @styra/opa to process the comments before returning them to the client, with the policies comment.rego and users.rego.

License

This demo is MIT licensed.

About

Demo repository for Next.js + React Server Components + @strya/opa

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 40.8%
  • CSS 31.9%
  • TypeScript 24.6%
  • Open Policy Agent 2.7%