• Stars
    star
    761
  • Rank 57,278 (Top 2 %)
  • Language
    TypeScript
  • Created 4 months ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Next AI News

A full-stack replica of HN using Next.js and AI generated content.

Design notes

  • Uses Next.js 14 with App Router and RSC on the Node.js runtime
    • All pages are server-rendered and dynamic, with no data caching
    • All mutations are done via Server Actions
    • Streaming is used throughout to maximize speed and concurrency
  • Uses pnpm for package management
  • Uses Drizzle ORM and Zod as the data layer
  • Uses Auth.js's Next-Auth for password authentication
  • Used v0 to generate all initial UIs with Tailwind, Shadcn UI and Radix UI
  • Developed entirely and tested with the new Next.js --turbo Rust compiler
  • Uses react-highlight-words for search highlights
  • PPR (experimental) is used to precompute the shells of pages
    • When deployed, these are served statically from the edge
    • This makes TTFB faster and speeds up CSS/fonts while origin streams
  • Deployed serverlessly on Vercel's Edge Network using:

AI

Deployment

  • Make sure the Vercel project is connected to a Vercel Postgres (Neon) database
  • Optionally, for rate limiting, add a Vercel KV (Upstash) database
  • Run pnpm drizzle-kit push:pg
  • Update metadataBase in app/layout.tsx to match your target domain

Local dev

  • Run vc env pull to get a .env.local file with your db credentials.
  • Run pnpm dev to start developing
  • For DB migrations with drizzle-kit:
    • Make sure ?sslmode=required is added to the POSTGRES_URL env for dev
    • Run pnpm drizzle-kit generate:pg to generate migrations
    • Run pnpm drizzle-kit push:pg to apply them

Performance

PageSpeed report for Emulated Moto G Power with Lighthouse 11.0.0, Slow 4G Throttling:

   💩 The SEO 98 score cannot be 100 without sacrificing stylistic fidelity to the original HN navigation

Codebase notes

  • Auth is initialized in app/auth.tsx, Drizzle in app/db.tsx.
  • Shared components are in ./components (exposed as @/components)
  • Only one component was not reused from npm / shadcn (components/time-ago.tsx)
    • I couldn't find something very light that worked well with server-rendering (takes a now prop with a timestamp)
  • The following db migrations were added manually:
    • CREATE EXTENSION IF NOT EXISTS pg_trgm; as part of #13
    • USING GIN (title gin_trgm_ops); as part of #13

TODO

This project is unique in that it's a full-stack replica of HN, with quite a few features. It'd be great for the community to fill in some important gaps, however:

  • Inline comment replies
  • "Forgot password" flow
  • Voting and ranking
  • "Next" and "Prev" comment links
  • Comment toggling
  • Flagging submissions and comments
  • Improve search further
  • Comment pagination
  • More efficient comment datastructures
  • Optimistic comments with useOptimistic
  • Local storage of comment and submission drafts
  • Improve the /next implementation after login
  • Add support for passkeys
  • A basic admin panel
  • User profiles

License

MIT

More Repositories

1

slackin

Public Slack organizations made easy
JavaScript
6,501
star
2

wifi-password

Get the password of the wifi you're on (bash)
Shell
4,352
star
3

blog

MDX
1,128
star
4

spot

Tiny file search utility (bash)
Shell
922
star
5

chat-example

HTML
798
star
6

weplay

Collaborative gameboy emulation powered 100% by JavaScript
JavaScript
601
star
7

how-is-this-not-illegal

A demo of using RSC and Vercel Postgres, legally
JavaScript
572
star
8

clif

Dead easy terminal GIFs, from the terminal.
JavaScript
447
star
9

node.websocket.js

WebSocket-compatible realtime HTTP server implemented with Node.JS
JavaScript
265
star
10

react-postgres-components

An experiment on deploying remote functions that run inside Postgres using v8
TypeScript
158
star
11

node.dbslayer.js

DBSlayer (MySQL) support for Node.JS
JavaScript
150
star
12

jamstack-ecommerce

JavaScript
129
star
13

wordledge

TypeScript
120
star
14

chrome-spdy-indicator

Chrome Extension to see an indicator of SPDY support in the address bar.
JavaScript
108
star
15

smashingnode

Repository for my book "Smashing Node"
JavaScript
107
star
16

TextboxList

MooTools tokenizer
JavaScript
101
star
17

gameboy

JavaScript
89
star
18

chromekit

HTML5 window chroming
JavaScript
64
star
19

insights-chrome

IO Insights chrome extension
JavaScript
58
star
20

emoji-todo

A simple app to demonstate the ease of fetching and mutating data with Next.js App Router, RSC, and Server Actions.
TypeScript
53
star
21

raycast-web-dev-measure

Raycast extension to quickly measure a site's performance using PageSpeed Insights
Shell
52
star
22

blog-views

JavaScript
49
star
23

genui-demo

TypeScript
49
star
24

pokeless

JavaScript
47
star
25

latency-io

Socket.IO echo example with latency measurement / graphing
JavaScript
42
star
26

jsconf-todo-demo

Demo application using socket.io+nodestream for realtime, express+mongoose for backend
JavaScript
36
star
27

blog-starter

JavaScript
34
star
28

berkshire-deck-demo

JavaScript
30
star
29

PluginsKit

Plugins repository for open source projects linked to GitHub
PHP
25
star
30

weplay-emulator

runs the emulator that communicates with the weplay io backend
JavaScript
24
star
31

express-trace

Express route/middleware tracer & profiler
JavaScript
21
star
32

s.js

tiny javascript sprintf
JavaScript
20
star
33

gitfollow

Add a GitHub followers badge to your website!
JavaScript
18
star
34

jsconfar

CSS
18
star
35

Cube5

A CSS3 animated 3D Cube layout
15
star
36

phpshortener

PHP URL Shortening encoder/decoder class.
PHP
14
star
37

APNG

Animated PNG cross-browser utility.
JavaScript
13
star
38

moogets

Guillermo's MooTools plugins.
JavaScript
13
star
39

gox-now

Example of cross-compiling Go on Now and hosting the resulting binaries in the Now CDN
Dockerfile
13
star
40

weplay-web

JavaScript
12
star
41

mongoose-meetup-04-05

Examples used for the presentation
JavaScript
11
star
42

pkg-now

Example of cross-compiling Node.js on Now and hosting the resulting binaries in the Now CDN
Dockerfile
10
star
43

oscon-chat

My oscon presentation chat app
JavaScript
10
star
44

define.js

Tiny Node.js script to pull definitions from Google
JavaScript
9
star
45

project-template-next.js

Next.js template for CodeSandbox Projects
TypeScript
8
star
46

datocms-Gatsby-portfolio-demo

CSS
7
star
47

ios6-bugs

Test cases for iOS6 Mobile Safari bugs
JavaScript
7
star
48

weplay-presence

JavaScript
6
star
49

mdx-deck-theme-berkshire

JavaScript
3
star
50

thereallybigone

CSS
3
star
51

brevity

Brevity is an operating system. It’s easy to use, free, and based on Linux‐ and web technologies.
JavaScript
3
star
52

inception.js

2
star
53

router

Fork of reach/router to demonstrate Now CI
JavaScript
2
star
54

belkirk-jekyll-demo

HTML
1
star
55

sample-app

JavaScript
1
star
56

blob-to-image

JavaScript
1
star
57

hi-fregante

HTML
1
star