<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rahul Bhooteshwar on Medium]]></title>
        <description><![CDATA[Stories by Rahul Bhooteshwar on Medium]]></description>
        <link>https://medium.com/@rahul-bhooteshwar?source=rss-cc4a54c7215e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dMyENC7neNtzyVMfLCWUVg.jpeg</url>
            <title>Stories by Rahul Bhooteshwar on Medium</title>
            <link>https://medium.com/@rahul-bhooteshwar?source=rss-cc4a54c7215e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:45:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahul-bhooteshwar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Async in Python Explained (for Developers Coming from JavaScript)]]></title>
            <link>https://medium.com/learnwithrahul/async-in-python-explained-for-developers-coming-from-javascript-45a96a0bc016?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/45a96a0bc016</guid>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Sat, 30 Aug 2025 16:46:57 GMT</pubDate>
            <atom:updated>2025-08-30T16:46:57.982Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bkYNajtPsPV_wxT1iXU6Vg.jpeg" /></figure><p>When I first started building apps in Python, I didn’t know about async/await. Coming from a JavaScript background, I always wondered: <em>how is Python handling concurrency without something like </em><em>Promise?</em></p><p>Recently, I discovered Python’s <strong>asyncio</strong> library — and it felt like déjà vu. Python has an async/await pattern too, but it works a bit differently than JavaScript. If you’ve ever asked yourself <em>“Do I need async in Python? When should I use it? How does it compare to Node.js?”</em> — this post is for you.</p><h3>1. How Python Works Without Async</h3><p>In JavaScript, everything runs on a single-threaded event loop. Async is the <strong>only way</strong> to handle concurrency at scale.</p><p>Python is different. If you don’t use async/await at all (say in a FastAPI app), your code runs <strong>synchronously</strong>. Each request blocks until it finishes.</p><p>So how does Python handle multiple users?</p><ul><li>Frameworks like <strong>FastAPI</strong> run sync endpoints in a <strong>threadpool</strong>.</li><li>Application servers like <strong>Uvicorn/Gunicorn</strong> spawn multiple worker processes.</li><li>The OS scheduler distributes requests across them.</li></ul><p>That means your app <em>can</em> handle many users even without async — but it scales using threads and processes, which consume more memory and CPU.</p><h3>2. How Async Python Works</h3><p>When you mark a function with async def in Python, it runs inside an <strong>event loop</strong> (just like Node.js).</p><p>Example in FastAPI:</p><pre>import asyncio<br>import httpx<br>from fastapi import FastAPI</pre><pre>app = FastAPI()</pre><pre>@app.get(&quot;/weather-and-news&quot;)<br>async def get_weather_and_news():<br>    async with httpx.AsyncClient() as client:<br>        weather_task = client.get(&quot;https://api.weatherapi.com/v1/current.json?q=London&quot;)<br>        news_task = client.get(&quot;https://newsapi.org/v2/top-headlines?country=us&quot;)</pre><pre>        # Run both requests in parallel<br>        weather, news = await asyncio.gather(weather_task, news_task)</pre><pre>    return {<br>        &quot;weather&quot;: weather.json(),<br>        &quot;news&quot;: news.json(),<br>    }</pre><p>Here, while the function is waiting for the weather API or news API, the event loop can serve <strong>other requests</strong>.<br> This means a single worker process can juggle <strong>thousands of concurrent connections</strong>, with far fewer threads.</p><h3>3. Sync vs Async in FastAPI</h3><ul><li><strong>Sync endpoint (</strong><strong>def)</strong> → Runs in a worker thread, blocks until done. Multiple threads = limited concurrency.</li><li><strong>Async endpoint (</strong><strong>async def)</strong> → Runs in the event loop, doesn’t block. Much higher concurrency for I/O-heavy apps.</li></ul><p>In short:</p><ul><li>Sync = works fine, easier if you use <strong>blocking</strong> libraries.</li><li>Async = more efficient, especially if your app is I/O-bound.</li></ul><h3>4. When Async Matters (and When It Doesn’t)</h3><p>✅ Use async if:</p><ul><li>Your app spends time waiting on <strong>databases</strong>, <strong>APIs</strong>, or <strong>files</strong>.</li><li>You want to handle <strong>long-polling, streaming, or WebSockets</strong>.</li></ul><p>❌ Async won’t help if:</p><ul><li>Your workload is <strong>CPU-bound</strong> (image processing, ML inference, encryption).</li><li>You’re stuck with <strong>blocking libraries</strong> (e.g., classic SQLAlchemy, boto3).</li></ul><p>In those cases, it’s better to:</p><ul><li>Offload heavy jobs to background tasks (Celery, RQ, Dramatiq).</li><li>Or run sync code in a threadpool (asyncio.to_thread).</li></ul><h3>5. Async in Python vs Async in JavaScript</h3><p>If you know Promise.all and Promise.allSettled in JS, Python has equivalents in asyncio:</p><p>JavaScript Python Promise.all([...]) await asyncio.gather(...) Promise.allSettled([...]) await asyncio.gather(..., return_exceptions=True) Promise.race([...]) await asyncio.wait(..., return_when=FIRST_COMPLETED)</p><p>Example:</p><pre># Run two async tasks in parallel<br>results = await asyncio.gather(task1(), task2())</pre><p>Looks very familiar, right?</p><h3>6. Common Mistakes With Async Python</h3><ul><li><strong>Mixing sync and async incorrectly</strong>:<br> Calling blocking code (like time.sleep() or requests.get()) inside an async function will freeze the loop. Always use async-compatible libraries (asyncio.sleep(), httpx, asyncpg, etc.).</li><li><strong>Expecting async to speed up CPU work</strong>:<br> Async doesn’t make heavy computation faster — it only frees the loop while waiting for I/O.</li></ul><h3>7. Final Thoughts</h3><p>So, is async Python well-known among Python developers?</p><ul><li><strong>Yes</strong>, in the <strong><em>web development world</em></strong> (FastAPI, aiohttp, Sanic).</li><li><em>Less so in data science, scripting, or older frameworks like Django/Flask.</em></li></ul><p>That makes it a great topic for developers crossing over from JavaScript:<br> 👉 Python does have <strong>async/await</strong>.<br> 👉 It works differently from Node.js because Python also has threads and processes.<br> 👉 Async is powerful, but only when used in the right places.</p><h3>TL;DR</h3><ul><li>FastAPI supports both sync and async endpoints.</li><li>Sync = threadpool, fine for many apps.</li><li>Async = event loop, better for I/O-bound apps.</li><li>Use asyncio.gather for parallel async tasks (like Promise.all).</li><li>Don’t use async for CPU-heavy work — use background jobs.</li></ul><p>That’s it! 🎉<br><strong><em>Coming from JavaScript, learning about async Python was a big aha moment for me. Hopefully, this post helps others bridge the gap too.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45a96a0bc016" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/async-in-python-explained-for-developers-coming-from-javascript-45a96a0bc016">Async in Python Explained (for Developers Coming from JavaScript)</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Ollama Remotely in a Secure Way ]]></title>
            <link>https://medium.com/learnwithrahul/running-ollama-remotely-in-a-secure-way-d14ba13c8d77?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d14ba13c8d77</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cloud-gpu]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[ollama]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 15:19:43 GMT</pubDate>
            <atom:updated>2025-06-28T15:19:43.668Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Practical Guide for Using Cloud GPU While Developing Locally</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTc6lr4-PieJsEZ1k8g0kA.jpeg" /><figcaption><a href="https://www.flaticon.com/free-icons">https://www.flaticon.com/free-icons</a></figcaption></figure><h3>What is Ollama, Quickly?</h3><p><a href="https://ollama.com/"><strong>Ollama</strong></a> is a <strong>lightweight local LLM server</strong> allowing you to run models like LLaMA, Mistral, Gemma, etc., on your machine using GPU/CPU and interact via a simple HTTP API (localhost:11434). It is popular among developers building AI workflows locally due to:</p><ul><li>Simplicity (no big infra setup)</li><li>Running fully offline</li><li>Familiar REST-like API</li><li>Fast prototyping with LangChain and other orchestration frameworks</li></ul><h3>Why Run Ollama Remotely?</h3><p>Sometimes:</p><p>✅ You <strong>need GPU power in the cloud (</strong>AWS, Lambda Labs, Vast.ai, MassedCompute, etc<strong>.)</strong><br> ✅ But your <strong>code, dev workflow, or even your production app runs on your local server, private network, or </strong>your laptop (development)<br> ✅ You want to <strong>use Ollama remotely while developing locally</strong> to avoid large model downloads and GPU limitations</p><p><strong><em>Example practical scenario:</em></strong></p><blockquote>You have a <strong>LangChain app</strong> running locally but want to <strong>offload LLM calls to a cloud GPU Ollama instance</strong>.</blockquote><h3>The Problem: Ollama Lacks Built-in Authentication</h3><p>If you simply expose 0.0.0.0:11434 on your cloud GPU server, <strong>anyone can hit your Ollama endpoint</strong>.<br> There is:<br> ❌ No built-in API key authentication<br> ❌ No user management<br> ❌ No rate limiting</p><p>So, <strong>how can you securely use Ollama remotely?</strong></p><h3>Solution 1: Secure Ollama with NGINX + Basic Auth</h3><p>1️⃣ <strong>Keep Ollama bound to </strong><strong>localhost:11434 on the cloud GPU server.</strong></p><p>2️⃣ Install and configure <strong>NGINX as a reverse proxy</strong>, exposing your desired public IP or domain.</p><p>3️⃣ Add <strong>HTTP Basic Authentication</strong> to NGINX to gate your Ollama server.</p><p>4️⃣ Use your <strong>credentials in your LangChain app or other HTTP clients</strong> when calling the API remotely.</p><p>🛠️ Example NGINX Config Snippet:</p><pre>server {<br>    listen 80;<br>    server_name your-cloud-server.com;<br><br>    location / {<br>        auth_basic &quot;Protected Ollama&quot;;<br>        auth_basic_user_file /etc/nginx/.htpasswd;<br><br>        proxy_pass http://127.0.0.1:11434;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>    }<br><br>    # if you wish a specific end point instead of the default &quot;/&quot;<br>    location /ollama/ {<br>        auth_basic &quot;Protected Ollama&quot;;<br>        auth_basic_user_file /etc/nginx/.htpasswd;<br><br>        proxy_pass http://localhost:11434/;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>    }<br>}</pre><p>Generate your password:</p><pre>sudo apt install apache2-utils<br>htpasswd -c /etc/nginx/.htpasswd your_username</pre><p>Reload NGINX:</p><pre>sudo systemctl reload nginx</pre><p><strong>🧩 Using With LangChain:</strong></p><pre>from langchain_ollama import ChatOllama<br>from langchain_core.messages import HumanMessage<br>import os<br>from dotenv import load_dotenv<br><br># Load environment variables from .env file<br>load_dotenv()<br><br>OLLAMA_HOST = os.environ.get(&quot;OLLAMA_HOST&quot;) # This should use proxy endpoint you exposed<br>OLLAMA_USER = os.environ.get(&quot;OLLAMA_USER&quot;) # basic auth user you setup on remote server<br>OLLAMA_PASS = os.environ.get(&quot;OLLAMA_PASS&quot;) # your basic auth password <br><br># Create ChatOllama with the base_url &amp; client_kwargs<br>chat = ChatOllama(<br>    base_url=OLLAMA_HOST,<br>    client_kwargs={<br>        &quot;auth&quot;: (OLLAMA_USER, OLLAMA_PASS)<br>    },<br>    model=&quot;llama3.2:latest&quot;<br>)<br><br>response = chat.invoke([<br>    HumanMessage(content=&quot;Who won 1983 cricket world cup?&quot;)<br>])<br><br>print(response.content)</pre><h3>Solution 2: SSH Port Forwarding (No Public Exposure via Proxy)</h3><p>If you <strong>do not want to expose any ports publicly</strong>:</p><ul><li>Keep Ollama running on localhost:11434 on your cloud GPU server.</li><li>From your local system, forward your local localhost:11434 to the remote server&#39;s localhost:11434 using SSH.</li></ul><p><strong>🛠️ Example SSH Tunnel Command:</strong></p><pre>ssh -f -N -i ~/.ssh/your_ssh_key_for_login -L 11434:localhost:11434 your-user@your-cloud-server-ip-or-dns-name</pre><p><em>If you use password-based SSH login on the remote server, omit the ssh key, it will ask for the password.</em></p><pre>ssh -f -N -L 11434:localhost:11434 your-user@your-cloud-server-ip-or-dns-name</pre><p>Now, on your local machine:</p><ul><li>Open http://localhost:11434 to access the remote Ollama.</li><li>Your local applications (LangChain, scripts, Postman) will <strong>think Ollama is local</strong>.</li></ul><p><strong>🧩 Using With LangChain:</strong></p><pre>from langchain_ollama import ChatOllama<br>from langchain_core.messages import HumanMessage<br><br><br># Create ChatOllama with default options<br>chat = ChatOllama(<br>    model=&quot;llama3.2:latest&quot;<br>)<br><br>response = chat.invoke([<br>    HumanMessage(content=&quot;Who won 1983 cricket world cup?&quot;)<br>])<br><br>print(response.content)</pre><blockquote>✨ <strong><em>No special configuration is required (just like the local Ollama server); it just works.</em></strong></blockquote><h3>Should You Use Ollama Remotely in Production?</h3><p>Ollama is fantastic for <strong>local development, experimentation, and low-scale internal workflows</strong>.</p><p>However, <strong>for production use cases</strong>:</p><p>⚠️ It lacks:</p><ul><li>Fine-grained user management</li><li>Rate limiting</li><li>Logging, metrics, tracing</li><li>Robust security features</li></ul><p>❌ It is <strong>not designed for multi-user high-scale workloads</strong>.</p><h4>Alternatives for Production:</h4><p>✅ <a href="https://huggingface.co/docs/text-generation-inference/index"><strong>Hugging Face TGI</strong> </a>(Text Generation Inference)</p><ul><li>Production-grade LLM inference server</li><li>Supports <strong>token-based authentication and multi-user scenarios</strong></li><li>Optimized GPU utilization</li><li>Integrates with LangChain</li></ul><p>✅ <strong>OpenAI API</strong> / <strong>Groq</strong> / <strong>AWS Bedrock</strong></p><ul><li>Managed, scalable, secure</li><li>Pay-per-use but no maintenance overhead</li></ul><p>✅ <strong>vLLM</strong> for open-weight model serving with better performance for production use.</p><h3>Final Thoughts</h3><p>Using <strong>cloud GPU for Ollama while developing locally</strong> is a highly practical approach for indie developers and small teams to <strong>get the best of both worlds</strong>.</p><p>If you:</p><p>✅ Need GPU power<br> ✅ Want to avoid local GPU/VRAM limitations<br> ✅ Want to keep your dev environment untouched</p><p>… then either:</p><ul><li><strong>NGINX + Basic Auth</strong> for securely exposing Ollama remotely, or</li><li><strong>SSH Port Forwarding</strong> for zero public exposure</li></ul><p>… will help you <strong>build faster without compromising your setup.</strong></p><blockquote>I will be back with more such learnings. Till then, <strong>Keep Learning, Keep Sharing &amp; Keep Rocking….</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d14ba13c8d77" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/running-ollama-remotely-in-a-secure-way-d14ba13c8d77">Running Ollama Remotely in a Secure Way 🚀</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TanStack Start: A New Framework Revolutionizing React Development]]></title>
            <link>https://medium.com/learnwithrahul/tanstack-start-a-new-framework-revolutionizing-react-development-4143de93fc7e?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4143de93fc7e</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 18:24:47 GMT</pubDate>
            <atom:updated>2025-02-10T19:03:03.855Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1pF2WquQXgw82L6_2Ag-g.jpeg" /></figure><p>In the ever-evolving world of web development, staying ahead means embracing tools that redefine possibilities. <a href="https://tanstack.com/"><strong>TanStack</strong></a>, known for its exceptional utilities like <em>React Table, Query, and Router</em>, has unveiled <a href="https://tanstack.com/start/latest"><strong>TanStack Start</strong></a> — a meta-framework addressing real-world performance and development challenges in <strong>Fullstack React apps</strong>. If you’re familiar with <strong>Next.js</strong>, you’ll find <strong>TanStack Start’s</strong> fresh take on these challenges intriguing.</p><h3>What is TanStack Start?</h3><p>TanStack Start is a React meta-framework built on <strong>TanStack Router</strong>, enhanced with server-side rendering (SSR) and “isomorphic loaders.” It simplifies data fetching and rendering while maintaining client-side routing power. Its standout features include <strong>streaming SSR</strong>, delivering fast and seamless user experiences. Unlike traditional frameworks, it’s lean, efficient, and purpose-driven.</p><h3>CSR vs. SSR: A Quick Overview</h3><h4>Client-Side Rendering (CSR)</h4><ul><li>Renders the app entirely in the browser.</li><li>Ideal for interactive apps like dashboards or SPAs.</li><li>Slower initial load due to large JavaScript bundles.</li></ul><h4>Server-Side Rendering (SSR)</h4><ul><li>Renders the app on the server, sending fully rendered HTML to the client.</li><li>Great for SEO-heavy and content-rich apps like blogs or e-commerce sites.</li><li>Increases server load but offers faster initial content display.</li></ul><p><em>Modern frameworks like </em><strong><em>TanStack Start</em></strong><em> and </em><strong><em>Next.js</em></strong><em> allow you to mix CSR and SSR for flexibility.</em></p><h3>What Are Isomorphic Loaders?</h3><p>One of TanStack Start’s standout features is <strong>isomorphic loaders</strong>. These loaders allow data fetching logic to run on both the server and the client, reducing code duplication and making applications more efficient. Unlike Next.js’s getServerSideProps or getStaticProps, which separate server and client logic, isomorphic loaders unify this process, leading to:</p><ul><li><strong>Better Maintainability</strong>: Less duplicate code across environments.</li><li><strong>Improved Performance</strong>: Data is available wherever it is needed without unnecessary re-fetching.</li><li><strong>More Flexibility</strong>: Works seamlessly with streaming SSR, reducing blocking render times.</li></ul><h3>What is <strong>Streaming SSR?</strong></h3><p><strong>Streaming SSR</strong> (Server-Side Rendering) is a technique that allows web pages to be rendered and delivered to the client in chunks rather than waiting for the entire page to be ready before sending it. This means that critical parts of the page can be displayed immediately while the rest of the content loads progressively.</p><h3>What Makes TanStack Router Special?</h3><p>At TanStack Start’s core is <a href="https://tanstack.com/router/latest"><strong>TanStack Router</strong></a>, a robust, flexible React router. Key features include:</p><ul><li>Declarative, type-safe APIs.</li><li>Advanced route matching.</li><li><strong>File-based routing</strong> for intuitive organization.</li></ul><p><em>This </em><strong><em>client-first</em></strong><em> router prioritizes local rendering and navigation, with SSR as an optional add-on for flexibility.</em></p><h3>Why a Client-First Approach Matters?</h3><p>A <strong>client-first</strong> approach means prioritizing rendering and interactions in the browser rather than relying heavily on the server. This brings several advantages:</p><ul><li><strong>Reduced Server Dependency</strong>: Less reliance on expensive backend computations.</li><li><strong>Improved Performance</strong>: Faster interactions, especially for real-time applications.</li><li><strong>Better Offline Support</strong>: Enables progressive loading and caching for seamless user experiences.</li></ul><p><em>This approach benefits apps with dynamic content, frequent user interactions, and real-time updates, such as dashboards, collaboration tools, and messaging apps.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*liwmwRPTNj4WHbNIp0avjw.jpeg" /></figure><h3>How is TanStack Start Different from Next.js?</h3><h4>1. Streaming SSR</h4><p>Unlike Next.js, which can block rendering while waiting for data, TanStack Start streams critical content immediately, loading slower data incrementally. This results in faster page interactivity.</p><h4>2. Isomorphic Loaders</h4><p>TanStack Start’s loaders work seamlessly on both the server and client, reducing code duplication compared to Next.js’s getServerSideProps or getStaticProps.</p><h4>3. Client-First Philosophy</h4><p>TanStack Start excels in dynamic, real-time apps with offline capabilities, such as dashboards or collaboration tools. While Next.js focuses on SSR and SEO, TanStack Start prioritizes responsiveness and interactivity.</p><h4>4. Flexibility Over Convention</h4><p>Next.js is great for rapid prototyping with its conventions but can feel restrictive in complex projects. TanStack Start provides granular control, suiting projects requiring customization.</p><h3>Deployment and Lock-In Considerations</h3><h4>TanStack Start</h4><ul><li><strong>Flexible Deployment</strong>: Deploy anywhere compatible with Node.js, including serverless functions.</li><li><strong>No Vendor Lock-In</strong>: Maintain control over your infrastructure.</li><li><strong>Out-of-the-box preset</strong> support for various popular platforms to run your application — <a href="https://tanstack.com/start/latest/docs/framework/react/hosting/#netlify">Netlify</a> , <a href="https://tanstack.com/start/latest/docs/framework/react/hosting/#vercel">Vercel</a>, <a href="https://tanstack.com/start/latest/docs/framework/react/hosting/#cloudflare-pages">Cloudflare-pages</a>, <a href="https://tanstack.com/start/latest/docs/framework/react/hosting/#nodejs">Node JS server</a> or a <a href="https://tanstack.com/start/latest/docs/framework/react/hosting/#bun">Bun Server</a></li></ul><h4>Next.js</h4><ul><li><strong>Optimized for Vercel</strong>: This offers additional features like Edge Functions, but relying on them could lead to vendor lock-in.</li><li><strong>Cost Considerations</strong>: Unnecessary SSR can <strong>increase costs on serverless</strong> platforms like Vercel.</li></ul><p><em>TanStack Start’s flexibility makes it ideal for teams wanting independence.</em></p><h3>What About Caching &amp; Rendering Strategies?</h3><p><strong>Next.js</strong> provides various rendering options like:</p><ul><li><strong>SSR (Server-Side Rendering)</strong>: Dynamic content fetched per request.</li><li><strong>ISR (Incremental Static Regeneration)</strong>: Static content updated periodically.</li><li><strong>SSG (Static Site Generation)</strong>: Content pre-built at deployment.</li><li><strong>Edge Functions</strong>: Execution at global edge locations for lower latency.</li></ul><blockquote>TanStack Start, with <strong>streaming SSR and isomorphic loaders</strong>, ensures data remains fresh without unnecessary re-renders. While it <strong>lacks built-in ISR</strong>, its flexible architecture allows developers to implement caching strategies as needed.</blockquote><h3>What to Expect from TanStack Start</h3><ol><li><strong>Blazing-Fast Performance</strong>: Critical content loads instantly with streaming SSR.</li><li><strong>Simplified Data Management</strong>: Isomorphic loaders streamline code.</li><li><strong>Advanced Routing</strong>: Built on the robust TanStack Router.</li><li><strong>Lightweight and Modern</strong>: Avoids bloat, prioritizing efficiency.</li><li><strong>Future-Proof</strong>: Continuously evolving with TanStack’s innovative tools.</li></ol><h3>Conclusion</h3><p><strong>TanStack Start</strong> is a compelling alternative to frameworks like Next.js, offering a fresh approach to SSR, routing, and data management. Its performance-first, client-driven philosophy makes it ideal for dynamic applications requiring speed, flexibility, and control.</p><p>If you’re looking for a framework that emphasizes efficiency and future-readiness, dive into <a href="https://tanstack.com/start/latest">TanStack Start</a> today.</p><blockquote>Currently TanStack Start is in <strong>Beta</strong>, but the community is already very excited and hopeful about this.</blockquote><blockquote>TanStack Team has already confirmed that there will not be any major breaking changes till it comes out of beta.</blockquote><blockquote>To <a href="https://tanstack.com/start/latest/docs/framework/react/getting-started">get started</a> Use the <a href="https://tanstack.com/start/latest/docs/framework/react/quick-start">Quick Start Examples</a> or <a href="https://tanstack.com/start/latest/docs/framework/react/build-from-scratch">Build a project from scratch</a>.<br>I have personally asked the question about TanStack CLI, &amp; the great @tannerlinsley himself confirmed that they are already working on the CLI.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ctFm-g_pKu8ldbKQKWD8w.png" /></figure><h4><a href="https://tanstack.com/">Don’t forget to checkout the full collection of amazing open source libraries built by TanStack Team today.</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*thirbMdRpOlKXv5r9Ciy5Q.png" /><figcaption>TanStack Libraries</figcaption></figure><p>I will be back with more such exciting stuff, till then, <strong><em>Keep Learning, Keep Sharing &amp; Keep Rocking</em></strong>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4143de93fc7e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/tanstack-start-a-new-framework-revolutionizing-react-development-4143de93fc7e">TanStack Start: A New Framework Revolutionizing React Development</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securely using NPM credentials with Docker]]></title>
            <link>https://medium.com/learnwithrahul/securely-using-npm-credentials-with-docker-f38b43bdb7c1?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f38b43bdb7c1</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Mon, 25 Apr 2022 14:08:03 GMT</pubDate>
            <atom:updated>2022-04-25T14:12:52.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYzmfYHnZAJVXDnrTH1GMA.jpeg" /></figure><p><em>Are you working on a </em><strong><em>NodeJS Application with Docker</em></strong><em> ? Do you use </em><strong><em>private NPM modules</em></strong><em> (registry.npmjs.org or your own module artifactory)? Most importantly, </em><strong><em>are you using NPM credentials securely while building your Docker images?</em></strong></p><p>If your answer to last question is “<strong>Not Sure</strong>” or “<strong>No</strong>”<strong>, </strong>following<strong> </strong>guide is worth reading and implementing ultimately.</p><p><strong><em>NOTE: this post assumes you have basic understanding around NodeJS, NPM &amp; Docker.</em></strong></p><h3>When do you need NPM credentials ?</h3><p>Most of the time you might be using <strong><em>public npm modules </em></strong>which can be installed without no extra setup, but if you are using some <strong>private npm modules</strong>, you will need to provide NPM credentials via <strong>.npmrc file. </strong>These credentials can be either single <em>Access Token or username, password, CA certs etc. </em>For simplicity, we will consider Token as access credential.</p><h3>Easy &amp; insecure approaches for providing <strong>.npmrc file </strong>to <strong>Docker Build</strong></h3><ul><li><strong>Copy .npmrc file</strong> with credentials to Docker Image during build</li><li><strong>Copy .npmrc file</strong> with placeholders (credential variables) to Docker Image, pass build arguments during build, embed build arguments as env values to .npmrc (automatically during <em>npm install</em>)</li></ul><h3>Why the above approaches are insecure?</h3><p><em>.npmrc files or npm credentials can be compromised if Docker image, image builder host, or the running container is compromised to theft!</em></p><p>Following are different places from where credentials can be leaked during a security incident:</p><ul><li>Stealing .npmrc file from running containers or image (if you leave it in image after build)</li><li>Stealing .npmrc file from intermediate images (layers): even if you delete .npmrc after npm install, it <strong>will leave traces in intermediate layers</strong> of Docker images</li><li>Leaking npm tokens in the image commit history — if you pass credentials as build args to Docker image build, it will again <strong>leave traces </strong>&amp; credentials can be easily recovered from image commit history</li><li>Leaking tokens in Docker container env values : if you used the second approach described in previous section, your credentials will live in Docker containers environment &amp; are subject to theft when Container is compromised</li></ul><h3>Using .npmrc securely</h3><p>There are 2 ways we can use .npmrc file to avoid above vulnerabilities:</p><ul><li>Use multi-stage docker builds</li><li>Use Docker build secrets</li></ul><p>Multi stage Docker build serves different purpose but was being used as a workaround (prior to build secrets) for securely passing npm credentials to Docker build.</p><p>As we already have <strong><em>build secrets </em></strong>support in Docker now, it is the <strong>recommended way </strong>for passing npm credentials.<br>To keep this post focused, we are only going to talk about <strong>using Docker build secrets</strong>.</p><h3><strong>Docker build secrets to rescue</strong></h3><p>You can easily configure your Dockerfile to receive .npmrc file <strong>via build secrets</strong>, that will not leave any trace after npm dependency installation is done. This is a 2 step process:</p><ul><li>Tweak <strong>Dockerfile to use .npmrc </strong>from build secrets</li><li>Pass <strong>.npmrc as build secret</strong> at the time of building the Docker image</li></ul><h4>Tweak <strong>Dockerfile to use .npmrc </strong>from build secrets</h4><figure><img alt="Using docker build secrets in Dockerfile with npm installation" src="https://cdn-images-1.medium.com/max/1024/1*ffjYLUmj-BsAYiZPCHnyGg.png" /><figcaption>Dockerfile with .npmrc as build secret for npm install</figcaption></figure><h4>Pass <strong>.npmrc as build secret</strong> at the time of building the Docker image</h4><figure><img alt="Passing .npmrc as build secret to Docker build command" src="https://cdn-images-1.medium.com/max/1024/1*NvPQhtOQPSemhgd3M--NQg.png" /><figcaption>Passing .npmrc as Docker build secrets during build phase</figcaption></figure><p>NOTE :<em> if you are building your Docker images in a CI/CD environment (Jenkins, Circle CI), you will need to provision the .npmrc file at some secure location on the builder host machine.</em></p><p><strong>This is it ! Your .npmrc credentials are now secure. It is just being used at the time of build &amp; not getting embed in Docker image and not leaving any traces in build history.</strong></p><p>Special Thanks to <strong>Alexandra Ulsh </strong>for 2 amazing posts that covered this stuff in details :</p><p><a href="https://www.alexandraulsh.com/2018/06/25/docker-npmrc-security/">https://www.alexandraulsh.com/2018/06/25/docker-npmrc-security/</a><br><a href="https://www.alexandraulsh.com/2019/02/24/docker-build-secrets-and-npmrc/">https://www.alexandraulsh.com/2019/02/24/docker-build-secrets-and-npmrc/</a><br> <br>I will be back with some more learnings, till then …</p><p><strong>Keep Learning, Keep Sharing &amp; Keep Rocking !</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f38b43bdb7c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/securely-using-npm-credentials-with-docker-f38b43bdb7c1">Securely using NPM credentials with Docker</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero downtime deployments with PM2]]></title>
            <link>https://medium.com/learnwithrahul/zero-downtime-deployments-with-pm2-93013713df15?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/93013713df15</guid>
            <category><![CDATA[pm2]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Thu, 08 Apr 2021 05:43:21 GMT</pubDate>
            <atom:updated>2021-04-08T05:43:21.531Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*iRVZdUtpz0Um_lMumhsTLA.png" /></figure><blockquote>PM2 is the most popular process management tool for Node/Express apps in production. It allows us to run Node/Express application as background process. Multiple running applications on a single machine can be managed with ease using PM2. If you wish to explore all the offerings from PM2 in detail you can <a href="https://pm2.keymetrics.io/docs/usage/quick-start/">read more here</a>.</blockquote><h4>Objective</h4><p>We are going to focus mainly around the process of achieving <strong>Zero downtime deployments with PM2. </strong>If you are not familiar with the basics of PM2, please read this <a href="https://pm2.keymetrics.io/docs/usage/quick-start/">Quick Start Guide</a> &amp; explore various possibilities with PM2.</p><h3>Zero Downtime Deployments</h3><h4>What &amp; Why?</h4><p><strong>Zero downtime deployments </strong>allows us to deploy new changes to already running application without impacting the application users. It is most likely that when we are doing deployment, some or many of our users are using the application. Pushing the new changes to a running Node/Express application <strong>requires application server restart .</strong> Most of the times Node/Express server requires some time after restart to be ready to accept requests from consumers due to various factors like <em>Database Connection(s), Logger setup, Web Socket setup, cron job schedules &amp; many more application specific needs</em>.</p><p>In order to ensure minimum business impact (downtime) due to the deployments, we should always ensure <strong>Zero downtime deployments.</strong></p><h4>How?</h4><p>We can utilise various PM2 parameters to achieve zero downtime deployment. We need to configure our restart command with various options (as per our requirements) &amp; minimal change in our code for this to work properly.</p><h4>Concepts</h4><p>Before we start, we need to explore a few terminologies in terms of PM2 to completely understand the whole configuration.</p><h4>Cluster Mode</h4><p>PM2 offers to run any Node/Express application in cluster mode.</p><p>The <strong>cluster mode</strong> allows networked Node. js applications (http(s)/tcp/udp server) to be scaled across all CPUs available, without any code modifications. This greatly increases the performance and reliability of your applications, depending on the number of CPUs available. <a href="https://pm2.keymetrics.io/docs/usage/cluster-mode/">Read More &gt;&gt;</a></p><p>So, basically we can run multiple instances of our application listening on same port &amp; these instances are automatically load balanced by PM2 in round robin fashion.<br>If we deploy our application in cluster mode &amp; use <strong>pm2 reload </strong>instead of<strong> pm2 restart, </strong>PM2 will restart these multiple instances one by one, so that we don’t have a downtime (as other worker processes are already running).</p><h4>wait-ready</h4><p>If we run our application with PM2 along with <strong>wait-ready</strong> configuration, during next redeployment (i.e. pm2 reload), it will <strong>wait for one instance to become ready to accept requests</strong> before moving to next instance for a restart. <br>This very common that Node/Express applications takes some time to be ready for serving user requests after a restart due to various factors like <em>Database Connection(s), Logger setup, Web Socket setup, cron job schedules &amp; many more application specific needs</em>.<br>This configuration requires one line of code in our application to signal that server is ready. This is done by running following line of code after we are done with all initialisation stuff mentioned above (DB setup etc.):</p><p>process.send(&#39;ready&#39;);</p><h4>listen-timeout</h4><p>By default, PM2 waits for 3s for an instance to signal “ready” (if we use wait-ready option mentioned above). If our server takes more than 3s, it will move to next instance restart without waiting further.<br>In order to fix the same, we need to specify <strong>listen-timeout </strong>with our start configuration. Suppose generally our server takes 5-8 seconds to be ready, we can specify a <strong>listen-timeout </strong>of 10000 (10s) to be on safer side. Now PM2 will wait for maximum of 10 seconds to get &quot;ready&quot; signal from an instance. If it gets ready signal before 1listen-timeout, it will move to next instance immediately for next instance restart.</p><h3>Configuring the startup command</h3><p>The above mentioned configuration can be achieved using following <strong>startup command</strong> &amp; above specified 1 liner code change.</p><p>pm2 start <strong>your_startup_file.js</strong> --name YOUR_APP_NAME -i 2 --wait-ready --listen-timeout 10000</p><p>Replace your_startup_file.js with your actual startup file (<strong><em>app.js, server.js, index.js</em> </strong>etc.). Apart from this, you can also change the listen-timeout value &amp; number of instances (-i) as per your need.</p><h3>Redeploying the changes</h3><ul><li>Pull the changes (git/zip download &amp; extract)</li><li>Run command <strong>pm2 reload </strong><em>YOUR_APP_NAME</em></li></ul><h3>A better way to manage startup configurations</h3><p>As we can see, now we have more flags with our startup commands &amp; it is more prone to mistakes while executing the startup command.<br>We can save this configuration to<strong> json/js</strong> file &amp; then use that file to execute startup command.<br>Create a file with a <strong>name of your choice </strong>(e.g. pm2.json, pm2.stage.json, pm2.prod.json etc.) in your project root (keep <strong>cwd</strong> in mind) &amp; add following configuration (modify as per your needs).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbXCP3hY4jXCEr-gW-zsAA.png" /><figcaption>PM2 app startup configuration</figcaption></figure><h3>Special Notes</h3><ul><li><strong>instance_var</strong> : This key is used to specify env var name for instance identifier. here we provided it as <strong>APP_INSTANCE_SEQ</strong>, but you can specify any string here. inside your code you can get value of instance identifier as <strong>process.env.APP_INSTANCE_SEQ (</strong>or whatever string you provided with instance_var). Instance identifier is helpful in identifying specific application instance to perform specific task on a single instance instead of all application instances, e.g. Cron job schedules - <strong>we don&#39;t want to do duplicate task execution while running multi instance setup.</strong></li><li><strong>restart_delay : </strong>If our application instances go down due to some unusual reason, PM2 will try to restart application instances automatically. In such cases, we don&#39;t want to bombard our resources (like DBs) continuously for startup connections. We can use this value to specify a <strong>delay for automatic restarts in case of failures</strong>.</li><li><strong>cwd: </strong>This is the working directory, relative to which PM2 looks for &quot;script&quot; (startup file). If you specify it as &quot;.&quot; (or keep unspecified), PM2 will look for startup file relative to directory from where startup command was executed.</li><li><strong>env</strong>: This can be used for injecting environment variables for our application instances. PM2 supports <a href="https://pm2.keymetrics.io/docs/usage/environment/">multi environment configuration setup</a> as well, but generally we do environment related stuff using system env vars or a .env files.</li><li><strong>RECOMMENDATION</strong> : PM2 supports <a href="https://pm2.keymetrics.io/docs/usage/application-declaration/#cli"><strong>multi-app configuration in a single file</strong></a> but it is better to use separate files for managing different configurations for <strong>prod, stage, dev</strong> &amp; so on - <strong><em>pm2.&lt;YOUR_ENV&gt;.json,</em></strong></li></ul><h3>Executing tasks on single instance</h3><p>As we will be running our application in cluster mode, every instance will be identical &amp; everything will be performed on all instances. But many times we need to do special things that should not be duplicated.<br>For example we have a <strong>cron job schedule, </strong>that runs every 12 hours.<br>If we have 3 instances of our application, every 12 hours our cron job will be executed 3 times but we don’t want to do that !!<br>In order to avoid such situation, we need to identify primary instance &amp; do those specific actions on that instance only. This can be easily done by <strong>APP_INSTANCE_SEQ</strong> env variable that we configured earlier.</p><p>so, suppose at the application startup, we are <strong>registering cron job schedule, </strong>we can check following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gnn54By0m3Sz9iFsOAQFhw.png" /><figcaption>Performing specific task on specific instance</figcaption></figure><p>I hope this comprehensive guide to setup your PM2 deployment will help you achieve zero downtime deployments for your next/existing project(s).</p><p>I will be back with more exciting content from my day to day technical learnings. So, stay tuned &amp;</p><h4>Keep Learning, Keep Sharing and Keep Rocking …. <strong>🔥🔥</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93013713df15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/zero-downtime-deployments-with-pm2-93013713df15">Zero downtime deployments with PM2</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Environment Variables with StencilJS]]></title>
            <link>https://medium.com/learnwithrahul/using-environment-variables-with-stenciljs-d3425592fa18?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3425592fa18</guid>
            <category><![CDATA[stencil]]></category>
            <category><![CDATA[stenciljs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Fri, 14 Jun 2019 19:28:58 GMT</pubDate>
            <atom:updated>2019-06-20T01:55:15.507Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Duxh3-NEIMzfEI48OpGzGQ.jpeg" /></figure><blockquote>Are you using or planning to use StencilJS for web component/application development? Have you ever required something that is environment specific &amp; needs to be replaced in your final build (at compile time)?</blockquote><p>So without any further delay let’s begin:</p><h3><strong>How Environment Variables are useful?</strong></h3><ul><li>We can have something that is specific to some particular environment build(dev/stage/prod), e.g. API host, hosted Style URLs, log levels (debug, error, trace, all)</li><li>Easy to manage configuration values using system/user variables or file</li></ul><h3>What do we want to achieve?</h3><ul><li>Read values from <strong><em>Operating System’s Environment Variables </em></strong>or a <strong>.env</strong> <strong>File</strong></li><li>Replace some keys with these values in our source code before building</li></ul><h3>Integrating Environment Variable read &amp; replace process</h3><blockquote>I suppose you have already created a Stencil project using <strong>npm init stencil</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*z3fdEl_gJ-Qh1tTdvuwIKA.png" /><figcaption>A sample stencil component project</figcaption></figure><p>1. Go to the project root &amp;<strong> install </strong><a href="https://www.npmjs.com/package/rollup-plugin-dotenv"><strong>rollup-plugin-dotenv</strong></a><strong> </strong>as dev dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*-sKf5wKKlAUgsQFlMg_8sA.png" /><figcaption>npm i rollup-plugin-dotenv @types/node -D</figcaption></figure><blockquote>or if you use <strong><em>yarn</em></strong></blockquote><blockquote>yarn add <strong>rollup-plugin-dotenv @types/node</strong> -D</blockquote><p>2. Open <strong><em>stencil.config.ts</em></strong> file in your preferred code editor</p><p>Import <strong>rollup-plugin-dotenv</strong> &amp; use it under <strong>plugins </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*Yj6Fr_MgUWf9GHCxYpoDlA.png" /><figcaption>Using <strong>rollup-plugin-dotenv</strong></figcaption></figure><p>3. You are all set to use Environment variables now</p><h4>Creating Environment Variables</h4><ul><li>You can either put your environment variables in OS’s system/user variables</li><li>or can <strong><em>create .env file at project root &amp; put the environment specific values</em></strong> in it</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*1cj7srhRIXTFwFq1HPFDWQ.png" /><figcaption>sample .env file</figcaption></figure><h4><strong>Using Environment Variables inside the component</strong></h4><p>It is pretty straight forward: access any value using <strong>process.env.SOMETHING</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6uBSKdFOBmUhU-ZxEBdsQ.png" /><figcaption>Using env values inside the component</figcaption></figure><blockquote>Hurray, we have used environment driven values in our Stencil Component</blockquote><h3>Things to remember</h3><ul><li><strong>@types/node</strong> typing must be installed (mentioned earlier) to avoid IDE/compilation error report on <strong><em>process.env </em></strong>thing as it is unknown to stencil &amp; typescript syntax!</li><li>Whenever you<strong> add/modify some env variable</strong> you will need to rebuild or <strong>restart your development server</strong></li><li><strong>.env</strong> file values <strong>take precedence</strong> over OS system/user variables. So if some variable is present at both the places, one that is contained inside<strong> .env</strong> file will be used</li><li>plugin first looks for a variable in .env file placed in project root &amp; if not found looks in systems environment variables</li><li><strong><em>Never commit </em></strong><em>.env file, as it is environment specific thing &amp; should be created as per the requirement. You can commit a sample .env.example file to guide anyone who needs to create .env file or system variables</em></li></ul><p><strong>I hope you enjoyed this story. If you liked it, please show your love with some claps. Stay tuned for some more exciting stuff containing my latest learnings.</strong></p><p><strong>Till then,</strong></p><blockquote>😊 Keep Learning, Keep Sharing, &amp; Keep Rocking 😊</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3425592fa18" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/using-environment-variables-with-stenciljs-d3425592fa18">Using Environment Variables with StencilJS</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Angular 6]]></title>
            <link>https://medium.com/series/exploring-angular-6-bfcd9cc7cb?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfcd9cc7cb</guid>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Fri, 04 May 2018 08:57:16 GMT</pubDate>
            <atom:updated>2018-05-04T09:01:20.519Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular 6: It is almost there…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*IDvB6l7iifLNV3Z585qv2Q.png" /></figure><blockquote>So, <a href="https://www.ng-conf.org/">ng-conf-2018</a> is over and it is everywhere… a feature loaded, enhanced and super heroic version of Angular Framework is on its way. Fasten your seatbelts and be prepared for an exciting journey ahead.</blockquote><p>If you are worried about the fact “one more upgrade! more backward compatibility issues, more problems and more effort!!”, so let me tell you it will not be like that. Most of the upgrade stuff should be smooth and it is worth upgrading to Angular 6.</p><p>Following are the key take aways from ng-conf-2018:</p><h3>Long Term Support for Angular</h3><p>Each major Angular version will be supported for atleast 12 months by Angular team. What is there for you? It means Angular team will release fixes/patches for the major version for 12 months and it will allow you to upgrade your application at your own pace.</p><h3>Version Alignment for library releases</h3><p>Currently Angular’s major libraries are not aligned with versioning strategy. From v6 those will be aligned with same version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*WJd-5y7wjuQI9U5_l3z0sQ.jpeg" /></figure><h3>New Angular Renderer “Ivy”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ZonDPQEIyupGMfnFGSgzxw.jpeg" /></figure><p>Not sure, if this will be part of first release of Angular 6 but this is really awesome thing that is going to happen behind the scenes of Angular framework. It is going to change the whole way of rendering Angular application. Don’t worry you need not to change anything to leverage it with V6. The way of writing angular templates will be same but behind the scene it will be a completely different process that will take Angular’s performance to a new level. It will also reduce the build size to a great extent. It will be really a jackpot for next generation Angular apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6k84ueWHoiXNJOHtK0GSoQ.jpeg" /><figcaption>Build size comparision with new renderer</figcaption></figure><h3>Providers with tree shakable capabilities</h3><p>Angular v6 will allow you to use a new API that will tree shake away the piece of code that is not required at the moment. That means, the initial bundle that user loads, will no require to pull out all the providers that your application needs. Ultimately further reducing the bundle size.</p><h3>Angular Elements: The long awaited feature is on its way…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*xbLiVHML2NMn5t0pdFmNkw.jpeg" /></figure><p>So, with Angular v6 you will be able to develop your components in Angular and bundle it within a single script, so that it can be used anywhere in any web application irrespective of the web technology.</p><p>Suppose you have developed an Angular component “World Clock widget”, that you want to include in a site that is using <strong>Adobe Experience Manager </strong>(AEM), or <strong>React</strong> or <strong>Vue</strong> or whatever!</p><p>You will be able to generate a bundle script for that component that you can include in your site and mention the component selector wherever required.</p><p>Isn’t it great? So now you will be able to use Angular in legacy projects that are not SPA but want to leverage features of Angular. It will also facilitate web transformation of legacy websites at your own pace.</p><h3>Angular CLI Features</h3><p>We all know that Angular CLI is a boon for the developers to automate some redundant tasks and generate code scafolding. It helped a lot to save project setup time and maintain code/directory structure consistency thoroughout the project.</p><h4>Extending the CLI with Schematics</h4><p>You might not be aware of Schematics, but you are already using it as a way to create, easily and fast, some type of files, like components, directives, pipes, services… but this is more than that. If you want to know more about schematics you can go <a href="https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2">check this out here</a>.</p><blockquote>With V6, New types of schematics will be available, that will be able to ease the integration of new libraries, add capabilities, and update your npm dependencies automatically (framework &amp; libraries), update your code and libraries too (RxJS + Material) inside your current Angular project.</blockquote><p>This will ease the upgrade process to future Angular version as it will automatically update the dependencies as well as your code wherever possible. It will also provide suggestions to change code as per the upgrade requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*o8eod8_rxK4FD0RauM9Bxw.jpeg" /></figure><p>Basically, using the new schematic ng add will looks like this:</p><pre>&gt; ng add @angular/pwa</pre><pre>&gt; ng add @angular/elements</pre><pre>&gt; ng add @angular/material</pre><pre>&gt; ng add @ng-bootstrap/schematics</pre><pre>&gt; ng add @clr/angular</pre><pre>&gt; ng add @nativescript/schematics</pre><h4>Generating library scaffolding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WG6Yxbz_1FKJ0AO4vjBvQg.jpeg" /></figure><p>This was also a long awaited feature. If you want to build a component library which can be published (private or public) for reuse, it is really a headache as of now. A lot of setup and scafolding effort is required. The Angular CLI can now be used to generate your Angular Library. This is something that the community wanted for a long time, and is finally here. Generating the library’s project scaffolding with all the basic features you will need to directly start coding. It will add test infrastructure and a build system too.</p><p>So, that was it as of now. Hope this will excite you for the upcoming superheroic features in Angular framework. Stay tuned for the details of the features, as I will be coming up with some more articles about these new features in depth.</p><p>Keep Learning..Keep Sharing..</p><h3>References</h3><ul><li><a href="https://medium.com/@bencabanes/what-is-coming-with-angular-6-4b059ecabb1">What is coming with Angular 6</a></li><li><a href="https://www.ng-conf.org/">ng-conf April 18-20th 2018 - The World&#39;s Original Angular Conference</a></li><li><a href="http://blog.rangle.io/dangerously-close-to-release-what-to-expect-in-angular-6-and-beyond/">What to Expect in Angular 6 and Beyond</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FdIxknqPOWms&amp;src_secure=1&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdIxknqPOWms&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FdIxknqPOWms%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8a205cc7416c3a04a5041d508b8145/href">https://medium.com/media/9c8a205cc7416c3a04a5041d508b8145/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfcd9cc7cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 6: It is almost there…]]></title>
            <link>https://medium.com/learnwithrahul/angular-6-it-is-almost-there-29adcc530933?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/29adcc530933</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-4]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Thu, 03 May 2018 07:25:41 GMT</pubDate>
            <atom:updated>2018-05-03T07:25:41.181Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*IDvB6l7iifLNV3Z585qv2Q.png" /></figure><blockquote>So, <a href="https://www.ng-conf.org/">ng-conf-2018</a> is over and it is everywhere… a feature loaded, enhanced and super heroic version of Angular Framework is on its way. Fasten your seatbelts and be prepared for an exciting journey ahead.</blockquote><p>If you are worried about the fact “one more upgrade! more backward compatibility issues, more problems and more effort!!”, so let me tell you it will not be like that. Most of the upgrade stuff should be smooth and it is worth upgrading to Angular 6.</p><p>Following are the key take aways from ng-conf-2018:</p><h3>Long Term Support for Angular</h3><p>Each major Angular version will be supported for atleast 12 months by Angular team. What is there for you? It means Angular team will release fixes/patches for the major version for 12 months and it will allow you to upgrade your application at your own pace.</p><h3>Version Alignment for library releases</h3><p>Currently Angular’s major libraries are not aligned with versioning strategy. From v6 those will be aligned with same version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*WJd-5y7wjuQI9U5_l3z0sQ.jpeg" /></figure><h3>New Angular Renderer “Ivy”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ZonDPQEIyupGMfnFGSgzxw.jpeg" /></figure><p>Not sure, if this will be part of first release of Angular 6 but this is really awesome thing that is going to happen behind the scenes of Angular framework. It is going to change the whole way of rendering Angular application. Don’t worry you need not to change anything to leverage it with V6. The way of writing angular templates will be same but behind the scene it will be a completely different process that will take Angular’s performance to a new level. It will also reduce the build size to a great extent. It will be really a jackpot for next generation Angular apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6k84ueWHoiXNJOHtK0GSoQ.jpeg" /><figcaption>Build size comparision with new renderer</figcaption></figure><h3>Providers with tree shakable capabilities</h3><p>Angular v6 will allow you to use a new API that will tree shake away the piece of code that is not required at the moment. That means, the initial bundle that user loads, will no require to pull out all the providers that your application needs. Ultimately further reducing the bundle size.</p><h3>Angular Elements: The long awaited feature is on its way…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*xbLiVHML2NMn5t0pdFmNkw.jpeg" /></figure><p>So, with Angular v6 you will be able to develop your components in Angular and bundle it within a single script, so that it can be used anywhere in any web application irrespective of the web technology.</p><p>Suppose you have developed an Angular component “World Clock widget”, that you want to include in a site that is using <strong>Adobe Experience Manager </strong>(AEM), or <strong>React</strong> or <strong>Vue</strong> or whatever!</p><p>You will be able to generate a bundle script for that component that you can include in your site and mention the component selector wherever required.</p><p>Isn’t it great? So now you will be able to use Angular in legacy projects that are not SPA but want to leverage features of Angular. It will also facilitate web transformation of legacy websites at your own pace.</p><h3>Angular CLI Features</h3><p>We all know that Angular CLI is a boon for the developers to automate some redundant tasks and generate code scafolding. It helped a lot to save project setup time and maintain code/directory structure consistency thoroughout the project.</p><h4>Extending the CLI with Schematics</h4><p>You might not be aware of Schematics, but you are already using it as a way to create, easily and fast, some type of files, like components, directives, pipes, services… but this is more than that. If you want to know more about schematics you can go <a href="https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2">check this out here</a>.</p><blockquote>With V6, New types of schematics will be available, that will be able to ease the integration of new libraries, add capabilities, and <strong>update your </strong><strong>npm dependencies automatically (framework &amp; libraries), update your code and libraries too (RxJS + Material) inside your current Angular project.</strong></blockquote><p>This will ease the upgrade process to future Angular version as it will automatically update the dependencies as well as your code wherever possible. It will also provide suggestions to change code as per the upgrade requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*o8eod8_rxK4FD0RauM9Bxw.jpeg" /></figure><p>Basically, using the new schematic ng add will looks like this:</p><pre>&gt; ng add @angular/pwa</pre><pre>&gt; ng add @angular/elements</pre><pre>&gt; ng add @angular/material</pre><pre>&gt; ng add @ng-bootstrap/schematics</pre><pre>&gt; ng add @clr/angular</pre><pre>&gt; ng add @nativescript/schematics</pre><h4>Generating library scaffolding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WG6Yxbz_1FKJ0AO4vjBvQg.jpeg" /></figure><p>This was also a long awaited feature. If you want to build a component library which can be published (private or public) for reuse, it is really a headache as of now. A lot of setup and scafolding effort is required. The Angular CLI can now be used to generate your Angular Library. This is something that the community wanted for a long time, and is finally here. Generating the library’s project scaffolding with all the basic features you will need to directly start coding. It will add test infrastructure and a build system too.</p><p>So, that was it as of now. Hope this will excite you for the upcoming superheroic features in Angular framework. Stay tuned for the details of the features, as I will be coming up with some more articles about these new features in depth.</p><p>Keep Learning..Keep Sharing..</p><h3>References</h3><ul><li><a href="https://medium.com/@bencabanes/what-is-coming-with-angular-6-4b059ecabb1">What is coming with Angular 6</a></li><li><a href="https://www.ng-conf.org/">ng-conf April 18-20th 2018 - The World&#39;s Original Angular Conference</a></li><li><a href="http://blog.rangle.io/dangerously-close-to-release-what-to-expect-in-angular-6-and-beyond/">What to Expect in Angular 6 and Beyond</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FdIxknqPOWms&amp;src_secure=1&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdIxknqPOWms&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FdIxknqPOWms%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8a205cc7416c3a04a5041d508b8145/href">https://medium.com/media/9c8a205cc7416c3a04a5041d508b8145/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29adcc530933" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/angular-6-it-is-almost-there-29adcc530933">Angular 6: It is almost there…</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Some Kick-Ass front End Libraries/Tools]]></title>
            <link>https://medium.com/learnwithrahul/introduction-to-some-kick-ass-front-end-libraries-tools-963f55152f4b?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/963f55152f4b</guid>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Sun, 18 Feb 2018 04:03:27 GMT</pubDate>
            <atom:updated>2018-02-18T04:03:27.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*J8s512OG7EN0U1VKWGtWkg.png" /></figure><blockquote>Are you writing a lot of code being it css , javascript or HTML for implementing basic features in your front end application? Do you want some really amazing features/utilities on your finger tips while doing front end development? Do you want your front end code to be cross browser compatible with fallback? If yes, following is the introduction to some hand picked, Kick-Ass front End Libraries/Tools.</blockquote><h3>Animate.CSS</h3><p><a href="https://daneden.github.io/animate.css/">Animate.css</a> is a simple but powerful css library for adding all types of animations to your HTML elements. It is just a matter of including a CSS file and applying desired animation class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*QKSiS0xAHaYknzv82-sQdQ.gif" /></figure><p>You can download the CSS or use the CDN version of the same. It is also available as <strong>npm and bower</strong> dependency.</p><p>Here is the full documentation: <a href="https://github.com/daneden/animate.css">https://github.com/daneden/animate.css</a></p><p><a href="https://daneden.github.io/animate.css/">Check out all the animations here!</a></p><h3>Single Element Spinners</h3><p><a href="https://projects.lukehaas.me/css-loaders/">Single Element Spinner</a> is an online tool to generate HTML and CSS code required for some really cool spinners that can be used as busy load indicators on your Front End interface.</p><p><strong>The tool provides the flexibility to choose foreground and background colors for the spinner.</strong> Once this is done you can simply view, copy and paste the required CSS and HTML from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXPNK6IpZVkY8hSWcnSR9w.gif" /></figure><h3><strong><em>is.js</em></strong></h3><blockquote>This is my favorite one!!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8arnSamJnhN3mKuIys2lWg.gif" /></figure><p><a href="http://is.js.org/"><strong><em>Is.JS</em></strong></a><strong><em> </em></strong>is a micro check library which provides a huge set of general utility checks for the following things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vl2tW1QqZdkG6OPWsFrJyw.png" /></figure><p>You will notice how easy it is to check for things like browser type, device type,Array/Strings and time etc.</p><p>It is again a matter of <strong>including a js file</strong> and you are all set with all kind of available <strong>checks! </strong>It is also available as <strong>npm and bower </strong>dependency.</p><p>Here is the full documentation: <a href="https://github.com/arasatasaygin/is.js">https://github.com/arasatasaygin/is.js</a></p><h3>Intro.js</h3><blockquote>Do you need to offer a tour guide to your first time application user?</blockquote><p>In order to implement a first user tour, you need not to implement the whole functionality from scratch. There is this amazingly cool utility called <a href="https://introjs.com/">Intro JS </a>for implementing it really quick.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gZ8AWhZXtBgMJgCJpE0hQ.gif" /></figure><p>The official site provides a <strong>quick demo</strong> and the <a href="https://introjs.com/docs/"><strong><em>documentation </em></strong></a>for the usage is also very rich.</p><p>It is not a free utility for <a href="https://introjs.com/#commercial"><strong>commercial use</strong></a><strong>. </strong>If you want similar functionality at no cost, there is an alternate utility called <a href="http://bootstraptour.com/"><strong>Bootstrap Tour</strong></a><strong>. </strong>It is based on bootstrap front end framework. If you don’t want bootstrap UI, you can also use the same without it.</p><h3><strong>Modernizr</strong></h3><p><a href="https://modernizr.com/">Modernizr</a> is a library that tells you what HTML, CSS and JavaScript features the user’s browser has to offer.</p><p>Many of the times, while using some modern web feature we are not sure if it will work in old browsers or how it will behave across the browsers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_qgRQ7VgoYngSHBuOPmJw.gif" /></figure><p><a href="https://modernizr.com/">Modernizr </a>provides a way to check for the feature’s compatibility in the user’s browser in advance(before rendering). If particular web feature is not supported in user’s browser you can provide a fallback mechanism to handle the scenario e.g. alternate implementation or just a simple message about compatibility issue!!</p><p>For getting started with Modernizr, here is the full <a href="https://modernizr.com/docs"><strong>documentation</strong></a><strong>.</strong></p><h3>Bonus</h3><p>Following are 2 very popular libraries in front end framework world. As these are quite popular and a lot of people are already aware about these, we are not going in details here:</p><p><a href="https://lodash.com/"><strong>Lodash</strong></a><strong> : </strong>Collection of very handy and useful utilities like operations on strings and data structures. <a href="https://lodash.com/docs/4.17.5">Documentation </a>covers it all.</p><p><a href="https://momentjs.com/"><strong>Moment</strong></a><strong>/</strong><a href="https://momentjs.com/timezone/"><strong>Moment Time Zone</strong></a><strong>: </strong>Moment JS provides the functionality of all date/time related functionality with ease. <strong>Moment time zone</strong> is the new feather in the cap for working across the time zones.</p><blockquote>So, that was it for the day. If you find any of the libraries/tools interesting and useful for your application, feel free to explore the official documentation and use it with ease. See the magic of this cool stuff yourself while using it with your front-end development tasks.</blockquote><p>We will be back soon with some more interesting stuff. Till then…</p><h3>Keep Learning…Keep Sharing…Keep Rocking</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=963f55152f4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/introduction-to-some-kick-ass-front-end-libraries-tools-963f55152f4b">Introduction to Some Kick-Ass front End Libraries/Tools</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Production Ready Angular Apps]]></title>
            <link>https://medium.com/learnwithrahul/building-production-ready-angular-apps-47d058c17aeb?source=rss-cc4a54c7215e------2</link>
            <guid isPermaLink="false">https://medium.com/p/47d058c17aeb</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[angular-4]]></category>
            <dc:creator><![CDATA[Rahul Bhooteshwar]]></dc:creator>
            <pubDate>Mon, 01 Jan 2018 10:27:28 GMT</pubDate>
            <atom:updated>2018-01-01T10:28:18.581Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*fQtcegyFMmrN1Gj-l9Io1Q.png" /></figure><blockquote>Are you done with development of your Angular based application? Are you planning to take your application into the production environment? Do you want your application to perform smoothly in production? Here are the things you should consider about the configuration and build of your application.</blockquote><p>This story is not about the details of the practices, configuration and strategy for taking the Angular applications in production. It is also not a tutorial about how to build Angular apps. This is just a check list of the things you might consider for the smooth operation of your application. Enough of the talking…let’s begin.</p><p><strong>Following are the things we are going to have a look further :</strong></p><ul><li>Compilation Method</li><li>Environment Configuration: Production Mode</li><li>Browser Compatibility</li><li>Location Strategy</li><li>Utilizing Caching and Cache Bursting features</li></ul><h3><strong>Compilation Strategy</strong></h3><p>There are mainly two compilation methods available for Angular apps</p><ul><li>JIT: Just In Time Compilation</li><li>AOT : Ahead Of Time compilation</li></ul><p>For production environment it is recommended that you use AOT compilation. This can be achieved by passing <em>— aot</em> option with <em>ng build</em> command. Read about the compilation methods in details <a href="https://angular-2-training-book.rangle.io/handout/aot/">here</a>.</p><h3><strong>Environment Configuration : Production Mode</strong></h3><p>Your application should always run in production mode when served to end user. Production mode is optimized by disabling things useful for developers only. This can be achieved by executing <a href="https://angular.io/api/core/enableProdMode">enableProdMode</a> function conditionally. While building the app using ng build, pass — environment=prod option, which ultimately uses the configuration stored in <strong>environments/environment.prod.ts.</strong></p><h3><strong>Browser Compatibility</strong></h3><p>When it comes to supporting majority of the browsers by your web application you should consider to have a look at Angular’s cross browser compatibility features and how to enable those.</p><p>You can enable various pollyfills to cover maximum browsers. Have a look at Angular’s cross browser compatibility in details <a href="https://angular.io/guide/browser-support">here</a>.</p><h3><strong>Location Strategy</strong></h3><p>As we know Angular enables us to develop SPAs (Single Page Applications). Client side routing enables us to render different view according to different URLs in a single page. Angular supports following schemes for URL formation:</p><ul><li>Hash (#) Based</li><li>Slash (/) Based (Default)</li></ul><p>In hash based location strategy your application URL with some route will look like: <strong>www.abc.com/#/dashboard </strong>or <strong>www.abc.com/#/orders</strong> etc.</p><p>The URL fragment after # is route name that decides which view should load on the page at client side.</p><p>In Slash (/) based location strategy regular address URLs are used for combining site address with client side routes. www.abc.com/<strong>dashboard</strong></p><p>It is the default strategy in Angular CLI based project.</p><blockquote><em>It is up to you which strategy you want to use for production but you need to consider some things while using </em>Slash (/) based location strategy.</blockquote><p>You need to set proper <strong>basehref </strong>and server side routing for every request containing address of your application to index.html of your application.</p><p>Read about Location Strategy in details <a href="https://codecraft.tv/courses/angular/routing/routing-strategies/">here</a>.</p><h3><strong>Utilizing Caching and Cache Bursting features</strong></h3><p>First thing first,<strong> <em>is browser caching of the Web Application good or bad??</em></strong></p><p>So, you guessed it correctly.. it is good but should be under control.</p><p>Caching of web pages (including other assets like styles and scripts) is something which is provided by all modern browsers for increasing application’s performance.</p><p>But when you release new features to your application which is already in production, this caching feature prevents the user to load latest site resources.</p><p>You can overcome this problem by utilizing Angular CLI’s features properly.</p><p>Use <strong>output-hashing</strong> option while building your application using ng build command. It will generate all the build files with different names (Hashed) on every new build. Configure your <strong>application server</strong> to <strong>disable caching</strong> of <strong>index.html (</strong>It is very small in size and we can live without caching it<strong>).</strong></p><p>Now your application’s index.html page is never cached in browser and user loads it always from server. Other files referenced from index.html are still cached in browser. Whenever new features are released index.html will point to different resources now and will load fresh version and again cache those.</p><p>So by following this strategy, we can use caching and cache bursting properly.</p><p>People generally complains that Angular build files are too large and may increase application load time. But if you are using caching feature smartly then application will load fast except the first time (After this all large files will be cached in browser).</p><p>So I guess we are done with it. The story was a little bit lengthy as i tried to cover all the things in one go. Still this is just an overview of the things under consideration. For going into the details please refer the links mentioned with various sections. <a href="https://github.com/angular/angular-cli/wiki/build">Angular CLI’s documentation</a> also explains all possible build options. Exploring those will also be very helpful.</p><p>I will be back with some more exciting stuff. Till then..</p><p><strong>Keep Learning — Keep Sharing — Keep Rocking</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47d058c17aeb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/learnwithrahul/building-production-ready-angular-apps-47d058c17aeb">Building Production Ready Angular Apps</a> was originally published in <a href="https://medium.com/learnwithrahul">Learn With Rahul</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>