šĀ package.json vs package-lock.json in React (and any Node project) When you create a React app, youāll always see two important files in the root folder:Ā package.jsonĀ andĀ package-lock.json. They work together but have different roles. 1ļøā£ package.json ā āProject blueprintā Created manually or viaĀ npm initĀ / create-react-app. Stores project metadata: name, version, scripts (likeĀ start,Ā build,Ā test). ListsĀ dependenciesĀ andĀ devDependenciesĀ with version ranges (e.g.Ā ^18.2.0). This is the file you edit when you add, remove, or update packages. 2ļøā£ package-lock.json ā āExact snapshot of dependenciesā Auto-generated when you runĀ npm install. You donāt edit it manually. LocksĀ exact versionsĀ of every dependency and sub-dependency installed. Ensures everyone on the team (and CI/CD) installs theĀ same versions, avoiding āworks on my machineā issues. Also helps faster installs because npm doesnāt need to resolve versions again. š”Ā In simple terms: package.jsonĀ ā What packages your React app needs. package-lock.jsonĀ ā The exact versions that were actually installed. ā Ā Best practice: CommitĀ bothĀ files to your repo. EditĀ package.jsonĀ when changing dependencies and let npm manageĀ package-lock.jsonĀ automatically. #React #JavaScript #NodeJS #WebDevelopment #packagejson #packagelockjson #Angular
package.json vs package-lock.json in React projects
More Relevant Posts
-
Most Node.js apps don't crash because of bad code. They crash because of bad error handling. Here's a pattern I use in almost every project: Instead of letting unhandled promise rejections silently kill your server, wrap your async route handlers in a reusable utility: const asyncHandler = (fn) => (req, res, next) => { Promise.resolve(fn(req, res, next)).catch(next); }; app.get('/user/:id', asyncHandler(async (req, res) => { const user = await getUserById(req.params.id); if (!user) throw new AppError('User not found', 404); res.json(user); })); app.use((err, req, res, next) => { res.status(err.status || 500).json({ message: err.message || 'Internal Server Error', }); }); That's it. One wrapper, one central error middleware, and your entire app handles errors consistently. The key insight: errors should flow to one place, not be scattered across every route with try/catch blocks copy-pasted everywhere. A custom AppError class lets you attach HTTP status codes and meaningful messages, so your API responses stay predictable for frontend teams. This also makes logging much easier ā you intercept everything in one middleware and send it to whatever logging service you use. Small pattern, big payoff. Your teammates will thank you, and your on-call rotations will get a lot quieter. What's the error handling pattern you swear by in your Node.js projects ā do you use something similar, or have you found a better approach? #nodejs #backend #javascript #softwaredevelopment #webdevelopment
To view or add a comment, sign in
-
-
Most React developers write custom hooks. But many of them donāt scale. You only realize this when your app grows. At first, hooks feel easy: Fetch data ā store state ā return it. Everything works⦠until: ā You need the same logic in multiple places ā Small changes break multiple screens ā Side effects become hard to track ā Debugging takes longer than expected The problem? We treat hooks like shortcuts instead of thinking about structure. What works better: ā Keep hooks small and focused ā Donāt hardcode logic ā pass it as input ā Separate fetching, logic, and UI ā Return consistent values (data, loading, error) ā Avoid unexpected side effects Simple mindset shift: Custom hooks are not just helpers. They define how your app handles data and logic. If a hook is poorly designed: ā it slows you down later If itās well designed: ā everything becomes easier to scale Some of the React issues Iāve seen, started with bad hooks, not React itself. Have you faced this with custom hooks? #React #Frontend #JavaScript #WebDevelopment #SoftwareEngineering #ReactJS #FrontendDevelopment #Programming #CleanCode #TechLeadership
To view or add a comment, sign in
-
What if you never had to build an API for your Laravel + Vue app? That's exactly what Inertia.js does. And in 2026, with v3 just released, it's better than ever. š Here's the idea: Instead of: Laravel API ā CORS ā token auth ā Axios ā state management ā Vue You get: Laravel controller ā Inertia ā Vue component (as props) Your controllers return Inertia::render() instead of JSON. Vue components receive data as props. Laravel handles routing, auth, validation, and sessions ā exactly as always. No duplication. No boilerplate. What Inertia v3 ships (March 2026): ā No more Axios ā built-in XHR client cuts ~15KB from your bundle ā useHttp hook ā reactive HTTP requests outside of page navigation (search, autocomplete) ā Optimistic updates ā instant UI changes with automatic rollback on error ā SSR works in npm run dev ā no more separate Node.js process during development ā useLayoutProps ā clean page-to-layout communication, no event bus needed And the features that were already amazing: ā useForm ā Laravel validation errors mapped to fields automatically ā Shared data ā auth user, flash messages available on every page ā Persistent layouts ā sidebar never re-renders between navigations ā Inertia::optional() ā lazy load expensive data only when needed I wrote the complete deep dive for installation to shared data, forms, persistent layouts, and when NOT to use Inertia. Are you already using Inertia.js? What stack are you pairing it with? #Laravel #InertiaJS #Vue #PHP #WebDevelopment #FullStack #100DaysOfBlogging
To view or add a comment, sign in
-
Every Node.js app eventually hits "I need rate limiting." You Google it. You find express-rate-limit. You install it. Then you realize: ā It only works with Express ā You also have a Next.js Edge route ā And a React frontend making too many API calls ā Oh, and you need Redis for production So now you're stitching 4 different libraries together. š That's exactly why I built limiterx. One package. Every runtime. ā Express, Koa, Node HTTP ā Next.js API routes + Edge Middleware ā React hook for client-side throttling ā Fetch + Axios wrappers ā Redis store out of the box ā 3 algorithms: fixed-window, sliding-window, token-bucket And it ships with zero runtime dependencies. Tree-shakeable. TypeScript-first. Works on Node, browsers, Edge, and Bun. Getting started is literally this: npm install limiterx Then: app.use(rateLimitExpress({ max: 100, window: '15m' })) That's it. If you're building anything in JS/TS that talks to an API ā this is for you. š npm: https://lnkd.in/gxbf3Jxt š GitHub: https://lnkd.in/gxt-RAi3 Drop a ā if this saves you a headache. And share with anyone building Node apps ā they'll thank you. #nodejs #javascript #typescript #webdev #opensource #ratelimiting #nextjs #developer
To view or add a comment, sign in
-
Running 6 projects locally shouldn't require 6 terminals, Docker Desktop, and 4 GB of RAM. I builtĀ AppNestĀ ā a 2 MB native app that replaces all of that. Add your projects. Pick a type. Hit Start. Done. The problem: Every day I juggle multiple web projects ā .NET APIs, React frontends, Node microservices. Each needs its own terminal, its own build commands, its own port. Close the wrong tab and you lose your logs. Docker Compose works but eats RAM, slows down hot reload through volume mounts, and turns private NuGet/npm feeds into a credentials nightmare. The solution: AppNest is a single executable with an embedded web dashboard. No installer, no runtime, no config files. It manages your apps as native processes ā same as running them from a terminal, but with a UI on top. What you get: ā One-click build & run for .NET, Node.js, React, Angular, Vue, Next.js, Express ā Dev & Release mode presets āĀ dotnet runĀ for dev, full publish pipeline for release ā Live color-coded logs with error highlighting and clickable URLs ā Built-in static file server with SPA fallback (no need forĀ npx serve) ā System tray ā runs in background, start/stop all from the tray menu ā Auto-start apps on launch, drag-and-drop reordering ā Persistent file-based logs with export ā Private feeds just work ā inherits your .npmrc, nuget.config, VPN, proxy settings What it costs: š¹ 2 MB on disk š¹ ~10 MB RAM at runtime š¹ Zero dependencies ā no Node.js, no Docker, no Electron Built with Rust, Axum, and Tokio.Ā The HTML/CSS/JS dashboard is compiled into the binary at build time via rust-embed. The server binds to localhost only ā nothing is exposed to the network. It's not a Docker replacement. Docker is the right tool for production, CI, and reproducible environments. AppNest is for theĀ developer inner loopĀ ā when you just want your apps running and visible while you code. Open source (MIT): https://lnkd.in/gq8TShnn If you've ever spent more time managing terminals than writing code ā give it a try. #OpenSource #DeveloperTools #Rust #DevProductivity
To view or add a comment, sign in
-
Designing Reusable Behavior in React with Custom Hooks āļø Before custom hooks, every single page in my React app looked like this: useState for data. useState for loading. useState for error. useEffect to fetch. Axios call. Error handling. Toast on success. Invalidate cache manually. Multiply that by 30+ pages. That's hundreds of lines of repeated logic. So I stopped copy-pasting and started building. ā useCustomQuery One hook. Every GET and POST request in the entire app. TanStack Query under the hood ā caching, gcTime, pagination, enabled flag ā all configurable. Pass the URL, method, and queryKey. Get clean data back. Zero boilerplate in the component. ā useCustomMutation One hook. Every create, update, and delete operation. Automatic query invalidation after success. Toast notification fires itself. Modal closes itself. Session expiry triggers logout via Axios interceptor. The component calls mutate() and forgets about the rest. ā useDebounceSearch 15 lines. Proper setTimeout cleanup.Configurable timer. Every search input in 30+ pages uses this one hook. Saves hundreds of unnecessary API calls every day.Search changes ā skip resets to 0 automatically. The component just renders. It has no idea how any of it works. The result? ⦠Components went from 80 lines to 20 ⦠New pages now take half the time to build ⦠Bugs are isolated ā fix once, fixed everywhere ⦠The entire team uses complex logic without understanding every detail Custom hooks didn't just clean up my code. They changed how I think about building React apps. Are you still writing the same logic in every component ā or have you made the switch to custom hooks? #ReactJS #Frontend #JavaScript #TypeScript #WebDevelopment #CleanCode #SoftwareEngineering #FrontendDevelopment #ReactHooks #TanStackQuery
To view or add a comment, sign in
-
š Mastering useState in React (Beyond the Basics) Most developers use useState. Very few actually master it. If you want to write scalable, high-performance React apps⦠this is where it starts š ā” 1. Think in āState Transitionsā, Not Variables useState is not just a variable ā it represents a change over time. š Always ask: What triggers this change? ā” 2. Use Functional Updates Like a Pro Avoid stale state bugs in async scenarios. ā setCount(prev => prev + 1) ā” 3. Keep State Minimal (Golden Rule) The more state you store ā the more re-renders you create. š Store only what you cannot derive. ā” 4. Split State for Better Performance Donāt dump everything into one object. ā Bad: const [state, setState] = useState({ name: '', age: 0 }) ā Better: const [name, setName] = useState('') const [age, setAge] = useState(0) ā” 5. Avoid Unnecessary Re-renders Every state update triggers a re-render. š Optimize using: useMemo useCallback Component splitting ā” 6. Know When NOT to Use useState Not everything belongs in state. š Use: useRef ā for mutable values constants ā for static data š” Real Mastery Insight: useState isnāt about managing data⦠Itās about controlling rendering behavior. š„ If you master this, your React code becomes: ā Cleaner ā Faster ā Production-ready š Follow for advanced React + Full Stack insights. #ReactJS #FrontendDevelopment #ReactHooks #JavaScript #WebDevelopment #PerformanceOptimization #CodingTips #FullStackDevelopment #SoftwareEngineering #LearnReact
To view or add a comment, sign in
-
-
CORS becomes very easy to understand with one real example. Imagine this: Youāre building a React app on http://localhost:3000 Your backend API is running on http://localhost:8000 From your frontend, you make a request: fetch("http://localhost:8000/api/profile") Looks normal, right? But the browser sees this as: Frontend ā localhost:3000 Backend ā localhost:8000 Same machine. Same localhost. Different port. And that different port is enough for the browser to say: āHold on ā this is a different origin. I need permission first.ā So before sending the real request, the browser asks your backend: āIs localhost:3000 allowed to access you?ā Thatās the CORS check. If your backend responds with: Access-Control-Allow-Origin: http://localhost:3000 The browser allows the request. If not, it blocks it and throws the CORS error. Thatās why this fails: fetch("http://localhost:8000/api/profile") Not because your API is broken. Not because React failed. But because the browser is protecting the user. And thatās the key thing most beginners miss: CORS is not a server error. Itās the browser asking the server for permission. Once you understand that, CORS stops feeling random. #Frontend #WebDevelopment #JavaScript #ReactJS #NodeJS #FullStack #SoftwareEngineering #Developers #TechConcepts
To view or add a comment, sign in
-
-
Your React app is slow. Here's why. š¢ Most devs jump straight to optimization tools. But 90% of the time, the fix is simpler: š“ Fetching data in every component independently ā Lift it up or use a global state solution š“ Importing entire libraries for one function ā `import _ from 'lodash'` hurts. Use named imports. š“ No lazy loading on heavy routes ā React.lazy() exists. Use it. š“ Images with no defined size ā Layout shifts kill perceived performance š“ Everything in one giant component ā Split it. React re-renders what changed, not what didn't. Performance isn't magic. It's just not making avoidable mistakes. Save this for your next code review. š #ReactJS #Frontend #WebPerformance #JavaScript #WebDev
To view or add a comment, sign in
-
Most developers try to optimize React apps⦠without knowing whatās actually slow. Thatās the problem. Before you optimize⦠You need to measure. Thatās where the React Profiler comes in š ā” What is React Profiler? A tool (inside React DevTools) that shows: ⢠Which components are re-rendering ⢠How long each render takes ⢠Why a component re-rendered š§ What it helps you discover ⢠Unnecessary re-renders ⢠Slow components ⢠Expensive computations ⢠Props/state changes causing re-renders š Real example You click a button and suddenly the whole page re-renders. Profiler shows: š A parent component updated š All child components re-rendered š Even the ones that didnāt need to š How to fix (after profiling) ⢠Wrap components with React.memo ⢠Use useMemo for heavy calculations ⢠Use useCallback for stable functions ⢠Avoid passing new object/array references š” Biggest mistake Optimizing blindly. Adding memoization everywhere⦠without knowing if it even helps. Measure ā Identify ā Optimize Thatās the correct flow. š” React performance is not about writing more code. Itās about writing smarter code based on data. Have you ever used React Profiler to fix a real issue? š #React #Frontend #WebPerformance #JavaScript #SoftwareEngineering #WebDevelopment
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development