All Projects → k2052 → vanilla-hn

k2052 / vanilla-hn

Licence: other
A Hacker News Reader in Vanilla JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
EJS
674 projects

Projects that are alternatives of or similar to vanilla-hn

Hnpwa Vanilla
Hacker News PWA implemented using no framework just javascript
Stars: ✭ 245 (+580.56%)
Mutual labels:  hacker-news
emacs-hnreader
Read Hacker News inside Emacs
Stars: ✭ 34 (-5.56%)
Mutual labels:  hacker-news
hackertab.dev
Hackertab turns your New Tab page into a geeky one that keeps you as a developer updated with the best tools, news, jobs and events.
Stars: ✭ 229 (+536.11%)
Mutual labels:  hacker-news
hnpwa-api
CDN cached Hacker News API
Stars: ✭ 73 (+102.78%)
Mutual labels:  hacker-news
tophn
An application to recommend the topmost story of Hacker News from the last 24 hours
Stars: ✭ 31 (-13.89%)
Mutual labels:  hacker-news
asyncio-hn
Python (asyncio) wrapper for hackernews api
Stars: ✭ 27 (-25%)
Mutual labels:  hacker-news
Hackerbuzz Reactnative
A Hacker News Reader built in React Native for iOS and Android
Stars: ✭ 220 (+511.11%)
Mutual labels:  hacker-news
hn-clojure
Hacker News in Clojure.
Stars: ✭ 31 (-13.89%)
Mutual labels:  hacker-news
reading-list
社区驱动的高质量聚合阅读列表
Stars: ✭ 45 (+25%)
Mutual labels:  hacker-news
HackerrankJAVA
This repository consists of Hackerrank JAVA Solutions
Stars: ✭ 31 (-13.89%)
Mutual labels:  hacker-news
hacker-news-mixin-bot
Post new hot stories from Hacker News to Mixin bot (Mixin ID: 7000100124)
Stars: ✭ 19 (-47.22%)
Mutual labels:  hacker-news
hnlookup
A chrome extension to browse for related topics on Hacker News (built with clojurescript)
Stars: ✭ 25 (-30.56%)
Mutual labels:  hacker-news
hackernews-button
Privacy-preserving Firefox extension linking to Hacker News discussion; built with Bloom filters and WebAssembly
Stars: ✭ 73 (+102.78%)
Mutual labels:  hacker-news
Awesome Hacker News
Awesome Hacker News: a collection of awesome Hacker News apps, libraries, resources and shiny things.
Stars: ✭ 250 (+594.44%)
Mutual labels:  hacker-news
Diurna
Basic/Classic Hacker News app, used as a Cocoa & Swift learning platform
Stars: ✭ 100 (+177.78%)
Mutual labels:  hacker-news
Devo
A Chrome and Firefox extension that displays GitHub Trending, Hacker News, Product Hunt and Designer News on every new tab.
Stars: ✭ 236 (+555.56%)
Mutual labels:  hacker-news
suomi.dev
Like Hacker News, but for Finns!
Stars: ✭ 27 (-25%)
Mutual labels:  hacker-news
hackernews-TUI
A Terminal UI to browse Hacker News
Stars: ✭ 347 (+863.89%)
Mutual labels:  hacker-news
hackernews-example
An NX Hacker News clone with real-time updates and animations.
Stars: ✭ 56 (+55.56%)
Mutual labels:  hacker-news
serializer
A linearizing social tech news reader
Stars: ✭ 89 (+147.22%)
Mutual labels:  hacker-news

Vanilla JavaScript Hacker News

This is a Hacker News client in plain vanilla JavaScript. It depends on zero frontend frameworks. There is no React, no Vue, no Ember, just modern JavaScript.

  • Uses zero frameworks on the client side
  • Fully universal with server side rendering and state hydration
  • An architecture much like a modern React stack

It takes many modern web-dev ideas and uses non-framework solutions to implement them. For JSX like templates, it uses template strings. For components, it uses functions that return template strings. For data-flow and effects, it uses async generators. For routing, it uses a simple switchPath function that matches a route to an async function that returns a component. The architecture is designed to reveal the problems that frameworks like React were built to solve.

Note: This is meant as a learning example and I highly recommend you use a framework in real world applications.

Installation

You can install all the dependencies by running:

$ yarn install

Usage

Running The App

You can start up a dev server by running:

$ yarn run dev

This will boot up webpack-dev-server on port 9000. There is no hot-reloading but the page will refresh when there are changes.

You can start the production server by running start:

$ yarn run start

Building

You can build the dev version of the app by running:

$ yarn run webpack

You can build the client by running

$ yarn run build.client

To build the server run:

$ yarn run build.server

Tests

Tests are done using Chai and Jest. You can run them like this:

$ yarn run test

Note: Run $ yarn run build.client the first time you run the tests or the test that tests assets are served will fail.

To get coverage details run:

$ yarn run coverage

Deployment

The app is designed to be static and once built to dist it can be deployed pretty much anywhere. It also comes with a SSR version that can be deployed to any node host.

Deploying to Zeit

To deploy to Zeit run:

$ yarn run deploy.zeit

Deploying to GitHub

To deploy to GitHub run:

$ yarn run deploy.gh

Architecture

The app is made up of components, events, and sagas.

The components are functions that take state and return a string representation of that state. They are a lot like React components except they use template strings instead of JSX and they don't use a virtual DOM. Instead of a virtual DOM we use innerHTML and keep track of what state has changed and the corresponding component for that state.

The events are a lot like Flux. They are plain objects that get passed into a Store; the store dispatches the events to Sagas to be processed and finally new state is generated which causes re-renders.

Sagas are async generators that respond to actions by yielding effects. Effects are where all the bad stuff is handled. They are where we do stuff that manipulates the state and the DOM.

You can read more about the app's architecture in the docs

Known Issues

  • Routes with the dev server are not universal i.e you can't bookmark a story and return to it -- a refresh returns a 404.
  • Needs to hashes for pages (e.g #ask) on the static version so URLS like /ask don't 404

Future Plans

  • Improved loading indicators
  • Login/Signup
  • hot-reload
  • Replace Koa usage with plain node http servers

Credits

The design of this is a direct port of next-news

License

Licensed under MIT

Hire Me

I'm looking for work! Drop me a line [email protected] if you are hiring.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].