Top Related Projects
The React Framework
The library for web and native user interfaces.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
web development for the rest of us
The best React-based framework with performance, scalability and security built in.
Build Better Websites. Create modern, resilient user experiences with web fundamentals.
Quick Overview
Nuxt/hackernews is a Hacker News clone built with Nuxt.js, a popular Vue.js framework. It serves as a demonstration of Nuxt.js capabilities, showcasing server-side rendering, routing, and state management in a real-world application.
Pros
- Excellent learning resource for Nuxt.js and Vue.js developers
- Demonstrates best practices for building scalable and performant web applications
- Implements server-side rendering for improved SEO and initial load times
- Provides a solid foundation for building similar news aggregation or content-driven websites
Cons
- May not include all features of the original Hacker News site
- Could become outdated if not regularly maintained to keep up with Nuxt.js updates
- Might be overly complex for beginners just starting with Vue.js or Nuxt.js
- Limited customization options without significant modifications to the codebase
Code Examples
- Fetching stories from the Hacker News API:
async function fetchItems (ids) {
return await Promise.all(ids.map(id => fetchItem(id)))
}
async function fetchItem (id) {
const item = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`)
return item.json()
}
- Implementing server-side rendering with Nuxt.js:
export default {
async asyncData ({ params }) {
const story = await fetchItem(params.id)
return { story }
}
}
- Creating a custom plugin for time formatting:
import Vue from 'vue'
import { format } from 'timeago.js'
Vue.filter('timeAgo', timestamp => format(timestamp * 1000))
Getting Started
To run the Nuxt Hacker News clone locally:
-
Clone the repository:
git clone https://github.com/nuxt/hackernews.git cd hackernews
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
to see the application running.
Competitor Comparisons
The React Framework
Pros of Next.js
- Larger ecosystem and community support
- More comprehensive documentation and learning resources
- Built-in TypeScript support and better performance optimizations
Cons of Next.js
- Steeper learning curve for beginners
- More complex setup and configuration for advanced features
- Less opinionated, requiring more decision-making from developers
Code Comparison
Next.js:
import { useRouter } from 'next/router'
function ActiveLink({ children, href }) {
const router = useRouter()
const style = {
marginRight: 10,
color: router.asPath === href ? 'red' : 'black',
}
const handleClick = (e) => {
e.preventDefault()
router.push(href)
}
return (
<a href={href} onClick={handleClick} style={style}>
{children}
</a>
)
}
Hackernews:
<template>
<router-link
:to="url"
:class="{ 'router-link-active': isActive }"
v-slot="{ navigate, isActive }"
>
<span @click="navigate" :class="{ active: isActive }">
<slot></slot>
</span>
</router-link>
</template>
<script>
export default {
props: ['url']
}
</script>
The code comparison shows that Next.js uses a more JavaScript-centric approach with React hooks, while Hackernews utilizes Vue.js template syntax and component structure.
The library for web and native user interfaces.
Pros of React
- Larger community and ecosystem, with more resources and third-party libraries
- More flexible and can be used for various types of applications beyond web
- Better performance for large-scale applications due to virtual DOM
Cons of React
- Steeper learning curve, especially for beginners
- Requires additional libraries for routing and state management
- More boilerplate code needed for setting up projects
Code Comparison
React component:
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
Nuxt/HackerNews component:
<template>
<h1>Hello, {{ name }}</h1>
</template>
<script>
export default {
props: ['name']
}
</script>
Additional Notes
- HackerNews is a demo project built with Nuxt.js, showcasing server-side rendering and Vue.js
- React is a more general-purpose library for building user interfaces
- HackerNews provides a pre-configured setup for building news applications
- React requires more setup but offers greater flexibility for various project types
Both projects have their strengths, with HackerNews being more focused and React offering broader application potential.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
Pros of Vue
- More comprehensive and flexible framework for building web applications
- Larger ecosystem with extensive plugins and community support
- Better suited for complex, large-scale applications
Cons of Vue
- Steeper learning curve for beginners
- Potentially more complex setup and configuration
- May be overkill for simple projects or prototypes
Code Comparison
Vue:
<template>
<div>{{ message }}</div>
</template>
<script>
export default {
data() {
return {
message: 'Hello Vue!'
}
}
}
</script>
HackerNews:
<template>
<div>{{ message }}</div>
</template>
<script>
export default {
asyncData() {
return { message: 'Hello Nuxt!' }
}
}
</script>
Summary
Vue is a more comprehensive framework suitable for large-scale applications, offering flexibility and a rich ecosystem. HackerNews, built with Nuxt.js, is more focused on server-side rendering and static site generation, making it ideal for content-heavy sites or quick prototypes. While Vue provides more control and customization options, HackerNews offers a simpler setup and faster development for specific use cases. The code comparison shows Vue's traditional component structure versus HackerNews' Nuxt-based approach with server-side data fetching.
web development for the rest of us
Pros of Svelte
- Smaller bundle sizes and faster runtime performance
- Simpler, more intuitive syntax with less boilerplate code
- Built-in reactivity without virtual DOM manipulation
Cons of Svelte
- Smaller ecosystem and community compared to Vue/Nuxt
- Less mature tooling and third-party library support
- Steeper learning curve for developers coming from traditional frameworks
Code Comparison
Svelte component:
<script>
let count = 0;
function increment() {
count += 1;
}
</script>
<button on:click={increment}>
Clicks: {count}
</button>
Nuxt/Vue component:
<template>
<button @click="increment">
Clicks: {{ count }}
</button>
</template>
<script>
export default {
data() {
return { count: 0 }
},
methods: {
increment() {
this.count++
}
}
}
</script>
The Svelte example demonstrates its more concise syntax and built-in reactivity, while the Nuxt/Vue example shows the traditional component structure with separate template and script sections. Svelte's approach often results in less code and a more straightforward development experience, but Nuxt/Vue's structure may be more familiar to developers coming from other frameworks.
The best React-based framework with performance, scalability and security built in.
Pros of Gatsby
- More extensive plugin ecosystem and larger community
- Better documentation and learning resources
- Supports a wider range of data sources and content management systems
Cons of Gatsby
- Steeper learning curve, especially for developers new to React
- Slower build times for large sites compared to Nuxt
- More complex setup and configuration process
Code Comparison
Gatsby (JavaScript):
import React from "react"
import { Link } from "gatsby"
export default function Home() {
return <Link to="/about/">About</Link>
}
Nuxt (Vue.js):
<template>
<NuxtLink to="/about">About</NuxtLink>
</template>
<script>
export default {}
</script>
Both Gatsby and Nuxt are popular static site generators, but they use different frameworks (React and Vue.js, respectively). Gatsby offers more flexibility and a larger ecosystem, while Nuxt provides a simpler development experience and faster build times for smaller projects. The code comparison shows how routing is handled in each framework, with Gatsby using React components and Nuxt using Vue.js templates. Ultimately, the choice between the two depends on the project requirements and the developer's familiarity with the underlying frameworks.
Build Better Websites. Create modern, resilient user experiences with web fundamentals.
Pros of Remix
- Full-stack framework with built-in server-side rendering and data loading
- Seamless integration with modern web APIs and progressive enhancement
- Strong focus on web standards and performance optimization
Cons of Remix
- Steeper learning curve due to its unique approach to routing and data handling
- Smaller ecosystem compared to more established frameworks like Nuxt
- Less flexibility in choosing backend technologies
Code Comparison
Remix (routing and data loading):
export default function Route() {
const data = useLoaderData();
return <div>{data.message}</div>;
}
export function loader() {
return { message: "Hello from Remix!" };
}
HackerNews (Nuxt-based routing):
<template>
<div>{{ message }}</div>
</template>
<script>
export default {
async asyncData() {
return { message: "Hello from HackerNews!" };
}
}
</script>
Summary
Remix offers a more opinionated, full-stack approach with a focus on performance and web standards. HackerNews, built with Nuxt, provides a more familiar Vue-based ecosystem with easier integration of existing Vue components. Remix excels in server-side rendering and data loading, while HackerNews benefits from Nuxt's simpler learning curve and larger community support.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Nuxt Hacker News
Hacker News clone built with Nuxt.
Demo
Hosted on Cloudflare Pages with NuxtHub:
npm run build
Performance
- Lighthouse 100/100 (Slow 4G / Mobile Moto G4)
Features
- Server Side Rendering
- Vite-based hot module replacement (HMR) dev environment
- Deploys anywhere with zero config (Vercel, Netlify, Cloudflare, etc.) powered by Nitro
- Code Splitting
- Prefetch/Preload JS + DNS + Data
Build Setup
Requires Node.js 14+
# install dependencies
npm install # or yarn
# serve in dev mode, with hot reload at localhost:3000
npm run dev
# build for production (server-side rendering)
npm run build
# serve in production mode (server-side rendering)
npm start
# validate and fix with ESLint (with Prettier)
npm run lintfix
Links
For the Nuxt 2 version, check out the nuxt2
branch
License
MIT
Credits
This repository is originally ported from vue-hackernews-2.0
Top Related Projects
The React Framework
The library for web and native user interfaces.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
web development for the rest of us
The best React-based framework with performance, scalability and security built in.
Build Better Websites. Create modern, resilient user experiences with web fundamentals.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot