今日已更新 498 条资讯 | 累计 20470 条内容
关于我们

标签:#X

找到 682 篇相关文章

开发者

Implementing Protected Routes and Authentication in React (2026 Edition)

This is an updated rewrite of my 2021 article on protected routes . A lot has changed in the React ecosystem since then. React Router moved from v5 to v7, class components have faded out, and the patterns we use for authentication state have matured. This version reflects how protected routes are built in modern React applications. Almost every web application requires some form of authentication to prevent unauthorized users from accessing parts of the application meant for signed-in users only. In this tutorial, I'll show how to set up an authentication flow and protect routes from unauthorized access using modern React patterns: function components, hooks, React Router v6+, and the Context API. First things first Install the dependency: npm i react-router-dom That's it. React Router v6 and above ships as a single package, so you no longer need to install react-router and react-router-dom separately. It is worthy of note that we will not be using Redux for authentication state in this version. For something as simple as "is the user logged in?", React's built-in Context API is the standard approach today. Redux still has its place, but it is overkill here. The Auth Context Instead of writing to localStorage directly from components and reading it in random places, we centralize authentication state in a context. This gives us a single source of truth and a clean useAuth() hook we can call anywhere in the app. Create ./src/auth/AuthContext.jsx : import { createContext , useContext , useState } from " react " ; const AuthContext = createContext ( null ); export function AuthProvider ({ children }) { const [ user , setUser ] = useState (() => { // Rehydrate on page refresh const saved = localStorage . getItem ( " user " ); return saved ? JSON . parse ( saved ) : null ; }); const login = async ( username , password ) => { // In a real app, this is an API call to your backend. // We simulate it here with hardcoded credentials. if ( username . toLowerCase () === " admin

2026-06-10 原文 →
AI 资讯

I Added x402 Payments to Base's Agent Skills — Here's How

If you build agents on Base, two things landed recently that are worth connecting. First: Base shipped its own Agent Skills. There's now a base/skills repo with consolidated skills that teach an AI agent to connect to Base, deploy contracts, authenticate wallets, and run nodes — installed with one command via Vercel's npx skills CLI. Second: that CLI is part of a fast-growing, cross-agent ecosystem most crypto devs haven't clocked yet. So this post does two things — explains how npx skills and skills.sh actually work, and shows where the payment layer in Base's skills stops and how to extend it with x402 pay-per-call and batch disbursement . What npx skills actually is npx skills is an open CLI from Vercel Labs for installing "skills" — modular SKILL.md files that teach an agent a specific capability without stuffing everything into its context window. A few things make it different from what crypto devs usually expect: GitHub is the registry. There's no central package server. Any public GitHub repo with a SKILL.md at its root is a valid, installable skill. Install with npx skills add owner/repo . It's cross-agent. The same skill installs into Claude Code, Cursor, Codex, GitHub Copilot, Goose, Windsurf, Gemini, and dozens more. You write once; it works across the agent you (or your users) actually run. skills.sh is the directory + leaderboard. It ranks skills by real install counts pulled from telemetry, with all-time, trending, and hot lists. There's no editorial submission step — you publish by putting a skill in a repo, and installs surface it. The format underneath — SKILL.md — is an open spec, which is why Base, Vercel, Anthropic, and a long tail of independent devs all use the same files. Here's Base's install, for reference: # Base's official agent skills npx skills add base/skills --skill build-on-base npx skills add base/skills --skill base-mcp build-on-base is a consolidated Base dev playbook; base-mcp wires up a Base MCP server that gives an agent a wall

2026-06-10 原文 →
开发者

From Blank Terminal to Shipping a Real Client Project: My First Year of Coding

Exactly one year ago, my terminal was a blank slate. I started where almost everyone does , wrestling with HTML, CSS, and JavaScript, trying to understand the web pixel by pixel. What began as curiosity quickly turned into a full obsession. I went from building simple static pages to diving deep into full-stack development. Here’s what that intense first year of constant building, breaking things, and shipping real projects has looked like. The Leap into Modern Frameworks Once vanilla JavaScript started feeling limiting, I jumped into React . Component-based thinking completely changed how I approached interfaces. Then came Next.js — it bridged client-side beauty with server-side power and pushed me into a true full-stack mindset. The Ultimate Test: Lynvista Safaris The biggest challenge was building lynvistasafaris.com , a live travel booking platform for a real client. This project forced me far beyond tutorials and into real engineering problems. I had to implement: Payment infrastructure from scratch with Daraja API (M-Pesa STK pushes) and Paystack for international transactions. A robust database layer using Drizzle ORM + MySQL. Custom business logic , including a multi-currency pricing system with special validation rules for currencies like GBP. It was messy , many late nights debugging webhooks, schema mismatches, and edge cases , but shipping it taught me more than any course ever could. What One Year Taught Me Syntax is just a tool. The real skill is learning how to break down complex problems, debug effectively, and keep iterating even when things break in production. I’m incredibly proud of the progress I’ve made in 365 days (402 contributions later), but I know I’m still at the very beginning. For the next phase, I’m focused on shipping more projects, writing about the crazy bugs I encounter, and deepening my architectural and full-stack skills. If you want to see what I’m building right now, check out my GitHub .

2026-06-10 原文 →
AI 资讯

I built an AI that reads stock charts — and made it grade its own homework

How KlineVision does AI technical analysis with Next.js + Gemini, draws it on the real candles, and verifies every call it makes after the fact — misses included. Most "AI stock analysis" tools confidently tell you a chart looks bullish and then never look back. I wanted the opposite: a tool that records every call it makes and later checks whether the market actually agreed — and publishes the hit rate, misses included. That one constraint — keep yourself honest — ended up shaping most of the interesting engineering. Here's how KlineVision is put together. What it does Type a ticker ( AAPL , 600519.SH , 0700.HK ) — or drop a chart screenshot. You get a structured read : trend, support/resistance, candlestick + chart patterns, and 缠论 (Chan theory) structure — drawn directly onto the real candles , not hand-waved in prose. Works across US, A-shares, and Hong Kong markets. The stack Next.js (App Router) on Vercel Supabase (Postgres + RLS) for data & auth Gemini 3 Flash for the analysis itself EODHD + Yahoo Finance for market data GitHub Actions + Vercel Cron for the background jobs PostHog for product analytics Now the parts that were actually interesting to build. 1. "Never analyze fake data" The market-data layer had a silent fallback: when a provider rate-limited, it returned synthetic candles so the UI never broke. Great for a demo, terrible for a product whose entire value is trust — the model would write a beautiful, confident analysis of a chart that never existed . The fix was to make the data layer fail honestly : Yahoo (primary) → EODHD (fallback) → if only demo data is available → 503, no analysis If we can't get real candles, the user gets "live market data temporarily unavailable" — not a hallucinated read. For a trust tool, a silent fallback to fake data is the worst bug on the board. 2. Make the AI show its work A text blob saying "there's a double bottom" isn't credible. You have to see it on the chart. So the model returns structured overlays keyed to

2026-06-09 原文 →
AI 资讯

Cursor tab completion not working in 2026: 8 fixes ranked by how often they actually work

This article was originally published on aicoderscope.com TL;DR : Cursor Tab (the inline ghost-text autocomplete) breaks in 8 distinct ways. Roughly 70% of cases are fixed in under a minute by checking three things: the toggle in Settings, your extension list for Copilot, and your usage quota. The remaining 30% need a corporate proxy fix or a toggle-restart cycle. After this guide you will: Know which of the 8 root causes matches your specific symptom Have the exact settings path and command for each fix Understand the 2,000-completion monthly cap on the Hobby plan that silently kills suggestions at month-end Honest take : Every "Cursor Tab is broken" thread in 2026 falls into one of these eight buckets. Go through the three-step quick check first — most readers fix it there. The 60-second triage: three checks before anything else Open Cursor and verify these in order. They resolve 70% of cases. 1. Is Cursor Tab actually enabled? Press Ctrl+Shift+J (Windows/Linux) or Cmd+Shift+J (Mac) to open Cursor Settings, then go to Features > Cursor Tab . The toggle should be on. If it's off — and this happens more than it should after updates — flip it, restart Cursor, done. You can also check from the status bar at the bottom right of the editor. A small "Tab" indicator shows whether inline completions are active. If it shows disabled, click it to re-enable. 2. Have you hit the free quota? On the Hobby plan, Cursor gives you 2,000 tab completions per month . During active coding at a normal acceptance rate, you can burn through 50–100 per hour. If you're late in the billing cycle, open Settings > Usage & Limits and check the completions counter. Completions reset on your account anniversary date, not the calendar month. When you hit 2,000/2,000, tab completion stops silently — no error, no banner, just nothing appearing. Upgrade to Pro ($20/mo) or wait for the reset. 3. Is GitHub Copilot or Tabnine installed? If you migrated from VS Code with extensions intact, you may have G

2026-06-09 原文 →
AI 资讯

Cx Dev Log — 2026-05-25

The interpreter's variable lookup is now blazing through arithmetic loops at a 57% faster pace. But this isn't just about raw speed — four tracker items were checked off the list, culminating in a more robust system. All rolled out on submain, a direct result of a thorough four-pillar audit. BindingId replaces string hashing at runtime The heavyweight change came from tracker #009. Previously, our interpreter was busy hashing variable names every time they were accessed. That was a repeat offender in wasted cycles. Now, by using a pre-assigned numeric BindingId, we seize efficiency. The semantic phase was already handing out these IDs, but the runtime kept adding the overhead back. It doesn’t anymore. ScopeFrame.vars has transitioned to a HashMap equipped with a zero-cost identity hasher keyed by u32 binding IDs. Name-based lookups are still around but tucked away for less frequent operations like string interpolation. Fixes were necessary upstream: ConstDecl and semantic_impls now hold onto their BindingId, making sure our semantic phase pipelines gracefully into the interpreter's primary key system — narrowing the gap with JIT's variable handling. Here's how the numbers shine on a Windows release build: arith_loop (5M iterations): from 5744ms down to 2481ms (56.8% boost) nested_loops (4M iterations): from 2675ms down to 1796ms (32.8% boost) fib_recursive: from 6835ms down to 6488ms (merely 5.1% faster due to call-frame constraints) Our findings align with expectations: recursive functions aren't bogged down by variable lookups as much as by setting up call frames. Array bounds errors stop lying Misleading diagnostic labels are on their way out, thanks to tracker #002 and #032. Attempts to access out-of-bounds array indices once triggered an error as unhelpful as variable 'index 5' has not been declared . Not anymore. Changes came in two waves. First, we introduced a new error variant: RuntimeError::IndexOutOfBounds { pos, index, length } . Then, three runtime.rs c

2026-06-09 原文 →
AI 资讯

Amazon is launching AI-generated custom merch

Amazon is expanding its print-on-demand features to AI-generated designs created using Alexa for Shopping for products like T-shirts, water bottles, and hoodies. Shoppers can use text prompts to generate images that are then printed on to blanks for sale on Amazon. They can then share the link to the design so other people can buy […]

2026-06-09 原文 →
AI 资讯

How I Built a Free SEO Audit Tool with Next.js, Supabase, and Stripe in 1 Week

Last weekend I started building SiteGrade — a free instant SEO audit tool that gives any website an A–F letter grade and the top fixes ranked by impact. I just launched it. This post is the build log: the architecture decisions that worked, the ones that didn't, and the gotchas you'd save time knowing about. If you're considering building a similar audit/scanner tool, or just want to see what a 2026 Next.js + Supabase + Stripe stack looks like in practice, this should be useful. Why I built it I got tired of family and friends asking me "how's the SEO on my website?" and not having a good answer to send back. Every existing tool I tried either cost $99+/month (Ahrefs, Semrush) or threw 200 metrics at people who just wanted to know if their site was OK. The wedge I built around: one letter grade, three top fixes, plain English, no signup. The paid tier ($29/mo) re-audits weekly and emails the report so non-technical users can track improvements as their developer makes them. The stack Nothing exotic. Everything is the obvious choice for a 2026 indie SaaS, which is the whole point — boring stack means I spent zero time fighting infrastructure and 100% of my time on the actual audit logic. Next.js 14 App Router — frontend + API routes in one repo Supabase — Postgres + auth + RLS + file storage, EU-hosted for GDPR Stripe — subscriptions + Billing Portal + webhooks Resend — transactional email (audit reports, weekly reports, Supabase auth via Custom SMTP) Vercel — hosting + cron jobs for the weekly re-audit cheerio — HTML parsing for the audit checks Google PageSpeed Insights API — Core Web Vitals + mobile performance Total monthly infrastructure cost at zero traffic: ~$0 (everyone on free tiers). At 100 paying customers it'd still be under $30/mo. The audit logic — what 15 checks look like in code Each audit runs 15 checks and produces a score from 0-100, then maps that to a letter grade (A: 90+, B: 75+, C: 60+, D: 45+, F: below 45). The checks are structured as pure fu

2026-06-08 原文 →
AI 资讯

I Built a Quote Generator Because Sometimes Finding the Right Words Is Hard

The Problem Wasn't Writing It was starting. Sometimes I wanted: A social media caption A motivational quote A writing prompt A meaningful message But my mind would go completely blank. Not because I had nothing to say. Because: Coming up with the right words at the right moment is surprisingly difficult. We've All Done This Open a new tab. Search: "Motivational quotes" "Success quotes" "Life quotes" "Funny quotes" Scroll for 10 minutes. Copy one. Close the tab. Why I Built This Tool So I built something simple: 👉 https://allinonetools.net/quote-generator-tool/ A tool that instantly generates quotes across different categories. Whether you need: Motivation Success Life Leadership Creativity Social media inspiration You can generate quotes in seconds. No signup. No setup. Just: Click → Generate → Use What I Realized People don't always look for quotes because they need content. Often they're looking for: A different perspective. A good quote can do something interesting. It can say in one sentence what takes us paragraphs to explain. The Surprising Part The most popular quotes are rarely complicated. They're simple. Short. Easy to remember. Yet somehow they stick with us for years. Why Quotes Still Matter In a world full of endless content: Attention is limited Time is limited Patience is limited A strong quote delivers an idea instantly. That's powerful. The Problem With Searching Manually Most quote websites feel: Cluttered Slow Full of ads Hard to browse And sometimes you spend more time searching than actually reading. What I Focused On I wanted the experience to feel: Fast Clean Inspiring Fun to explore Because finding inspiration shouldn't require effort. What Surprised Me After building it: Some people used it for: Social posts Presentations Daily motivation Writing inspiration But one thing surprised me most. People kept generating quote after quote. Not because they needed one. Because they enjoyed discovering them. The Real Insight Sometimes tools aren't abo

2026-06-08 原文 →
AI 资讯

Learning DevOps from First Principles: What an EC2 Instance Actually Is

One of the first cloud concepts many people encounter while learning AWS is EC2 . The name sounds technical. The documentation is extensive. And the number of configuration options can make it feel like something fundamentally different from a regular computer. But while trying to understand cloud computing, I found myself repeatedly coming back to a simple thought: At the end of the day, an EC2 instance is just another computer. That realization helped me understand cloud infrastructure much more clearly. The Intimidation Factor When people first open the AWS console, they encounter terms such as: EC2 VPC Security Groups Elastic IPs Auto Scaling It is easy to feel that cloud computing is an entirely different world. But before diving into those concepts, it helps to ask a simpler question: What is an EC2 instance actually providing? Starting with the Name EC2 stands for: Elastic Compute Cloud The important word here is: Compute AWS is essentially renting computing resources. When you launch an EC2 instance, AWS allocates: CPU Memory (RAM) Storage Networking to a virtual machine that you can access. In other words: You are renting a computer that lives inside AWS's infrastructure. Comparing It to a Personal Computer Consider a typical laptop. It contains: A processor RAM Storage An operating system Network connectivity Now consider an EC2 instance. It also contains: Virtual CPUs RAM Storage An operating system Network connectivity The location is different. The concepts are the same. The Main Difference: Ownership The biggest difference is not technical. It is operational. With a personal computer: You own the hardware. The machine sits near you. You maintain it. With EC2: AWS owns the hardware. The machine runs in a data center. AWS manages the physical infrastructure. You only manage the virtual machine running on top of it. Why Linux Knowledge Transfers This was one of the most interesting observations during my learning. If an EC2 instance runs Linux, many of th

2026-06-08 原文 →