Why Svelte is converting TypeScript to JSDoc

#​638 — May 11, 2023

Read on the Web

JavaScript Weekly

The JavaScript Ecosystem is Delightfully Weird — There are plenty of examples of how JavaScript is weird but Sam focuses on the why. If you’ve been a JS developer for many years you’ll have seen it go through many phases and morph to fit its environment. Sam paints the big picture, concluding with a talk Dan Abramov gave yesterday called “React from Another Dimension.”

Sam Ruby

The New JS Features Coming in ECMAScript 2023 — The next JavaScript update brings smaller additions familiar from other languages, but there are more significant developments waiting in the wings. 

Mary Branscombe (The New Stack)

Full Stack for Front-End Engineers with Jem Young (Netflix) — Learn what it means to become a well-rounded full-stack engineer with this hands-on video course. You’ll dive into servers, work with the command line, understand networking and security, set up continuous integration and deployment, manage databases, build containers, and more.

Frontend Masters sponsor

Vue 3.3 ‘Rurouni Kenshin’ Released — Named after a popular manga series, the latest release of Vue is focused on developer experience improvements, particular for those using TypeScript.

Evan You

John Komarnicki says ▶️ Vue 3.3’s defineModel macro will change the way you write your components.

Next.js 13.4 Released — Despite the minor version bump, this is a big release for the popular React framework. The new app router and its improved approach to filesystem based routing is now offered as a stable feature, with a new concept of server actions being introduced in alpha as a way to mutate data on the server without needing to create an in-between API layer.

Tim Neutkens and Sebastian Markbåge

⚡️ IN BRIEF:

???? Svelte is converting from TypeScript to JSDoc (example).. sort of. Rich Harris popped up on Hacker News to provide some all important context but the ultimate result will be smaller package sizes and a better experience for Svelte’s maintainers.

React now has official ‘canary’ releases if you want to use newer features than in the stable releases but still be on an officially supported channel.

Newly released Firefox 113 lets you override JS files in its debugger.

No stranger to controversy, Ruby on Rails’s David Heinemeier Hansson (DHH) tweeted: ???? “TypeScript sucked out much of the joy I had writing JavaScript.”

RELEASES:

Glint 1.0 – TypeScript powered tooling for Glimmer / Ember templates.

Elementary 2.0 – JS/C++ library for building audio apps.

???? Articles & Tutorials

ES2023’s New Array Copying Methods — The newest ECMAScript spec introduces some new methods on Array that you’ll eventually find useful in your own programs. Phil gives us the tour.

Phil Nash

Private Class Fields Considered Harmful“As a library author, I’ve decided to avoid private class fields from now on and gradually refactor them out of my existing libraries.” Why? Well, that’s the interesting part..

Lea Verou

▶  I’m Done with React — Going from least-to-most important, the reasons this developer isn’t choosing React for future projects make for interesting watching, particularly if you too are overwhelmed by upheaval in the React world. Solid is one of the alternatives he has warmed to.

Adam Elmore

Constraining Language Runtimes with Deterministic Execution — Explore various challenges encountered while using different language runtimes to execute workflow code deterministically.

Temporal Technologies sponsor

Running JavaScript in Rust with Deno — Deno’s use of Rust makes it a natural choice if you’re building a Rust app and want to integrate a JavaScript engine.

Austin Poor

Regular Expressions in JavaScript — Powerful but often misunderstood, many will benefit from this roundup of the potential regexes offer to JavaScript developers.

Adebayo Adams

How to Measure Page Loading Time with the Performance API — The Performance API is a group of standards used to measure the performance of webapps supported in most modern browsers.

Silvestar Bistrović

How to Build a JS VST or Audio Unit Plugin on macOS — VSTs and Audio Units are both types of audio plugins for audio editing software and they’re usually built in C or C++. This tutorial doesn’t dig into the audio side of things, but more the practicalities of packaging things up to get started.

Chris Mendez

An Introduction to the Bun Runtime — If you’ve not yet played with the newest entrant into the JS runtime space, this is a high level overview.

Craig Buckler

2023 State of the Java Ecosystem

New Relic sponsor

Configuring ESLint, Prettier, and TypeScript Together

Josh Goldberg

DestroyRef: Your New Angular 16 Friend

Ion Prodan

Why Astro is My Favorite Framework

Ryan Trimble

???? Code & Tools

file-type 18.4: Detect the File Type of a Buffer, Uint8Array or ArrayBuffer — For example, give it the raw data from a PNG file, and it’ll tell you it’s a PNG file. Uses magic numbers so is targeted solely at non text-based formats.

Sindre Sorhus

Learn How the Rising Trend of Malicious Packages Can Affect Your Apps — Keep your applications secure with Snyk’s article on the increasing number of malicious OS packages and ways to mitigate these risks.

Snyk sponsor

Livefir: Build Reactive HTML Apps with Go and Alpine.js — Go isn’t a language that often pops up in the context of the frontend, but this is a neat integration between Go on the backend and Alpine.js up front.

Adnaan Badr

JZZ.js: A Developer Friendly MIDI library — For both browsers and Node, JZZ.js provides an abstraction over working with MIDI related concepts. There are many examples, but the easter egg in the top left is our favorite.

Sema / Jazz-Soft

htmlparser2 9.0: A ‘Fast and Forgiving’ HTML and XML Parser — Consumes documents and calls callbacks, but it can generate a DOM as well. Works in both Node and browser.

Felix Böhm

cRonstrue: Library to Convert cron Expressions into Human-Readable Form — Given something like */5 * * * *, it’ll return “Every 5 minutes”. No dependencies.

Brady Holt

Knip: Find Unused Files, Dependencies and Exports in TypeScript Projects — Being Dutch for “snip” is appropriate as Knip can trim away things that aren’t being used in your project.

Lars Kappert

jsPlumb 6.1
↳ Visual connectivity for webapps.

gridstack.js 8.1
↳ Build interactive dashboards quickly.

???? Jobs

Find JavaScript Jobs with Hired — Hired makes job hunting easy-instead of chasing recruiters, companies approach you with salary details up front. Create a free profile now.

Hired

Team Lead Web Development — Experienced with Node, React, and TS? Join us and lead a motivated team of devs and help grow and shape the future of our web app focused on helping millions explore the outdoors.

Komoot

????‍???? Got a job listing to share? Here’s how.

???? Don’t tell Satya Nadella..

Fake Windows 11 in Svelte — This is a cute little side project, and the code is available too. The most common complaint I’ve seen is that it’s actually more responsive than the real Windows.. ???? Be sure to check out both ‘VS Code’ and ‘Microsoft Edge’ in this environment.

Yashash Pugalia

???? Prefer Windows XP? Maybe RebornXP is more for you. Complete with the classic starting up sound!

Flatlogic Admin Templates banner

JavaScript sans build systems?

#​626 — February 17, 2023

Read on the Web

JavaScript Weekly

Writing JavaScript Without a Build System — Using a variety of build tools for things like bundling and transpiling is reasonably standard in modern JavaScript development, but what if you want to keep things simple? For simple things, it’s not necessary, says Julia. This led to a lot of discussion on Hacker News.

Julia Evans

Ryan Dahl, Node.js Creator, Wants to Rebuild the Runtime of the Web — A neat bit of journalism about the alternative JavaScript runtime Deno and what Ryan Dahl is trying to achieve with it and how Ryan handled the stress of being known as the creator of Node.js.

Harry Spitzer / Sequoia

Broadcasting a Live Stream With Nothing but JavaScript — Live streams typically use third-party software to broadcast, but with Amazon Interactive Video Service, you can build a powerful, interactive broadcasting interface with the Web Broadcast SDK and JavaScript. Click here to learn more.

Amazon Web Services (AWS) sponsor

core-js’s Maintainer Complains Open Source Is ‘Broken’core-js is a popular universal polyfill for JavaScript features and its author has run into his fair share of bad luck which has culminated in this lengthy post on the state of the project, his issues in securing an income and, well, the downsides to living in Russia. The Register has tried to balance out the story.

The Register

IN BRIEF:

? The just released Firefox 110 for Android now supports Tampermonkey, an extension for running JavaScript ‘userscripts’ on sites you visit.

The Angular project is taking steps to revamp its reactivity model to enable fine-grained change detection via signals.

The latest beta of iOS and iPadOS 16.4 supports the Web Push API for home screen webapps.

? A fun Twitter thread where Qwik’s Miško Hevery attempted to demonstrate why a = 0-x is about 3-10x faster than a = -x before being told about a flaw in his benchmark. There is still a performance difference, though.

▶️ The React.js documentary we mentioned last week has now been released and it’s a heck of a watch – you’ll need 78 minutes of your time though.

RELEASES:

Node.js 19.6.1, 18.14.1, 16.19.1 and 14.21.3.

JavaScript Obfuscator 4.0 – Code scrambler.

Shoelace 2.1
↳ Framework agnostic Web components.

Mermaid 9.4
↳ Text to diagram generator. Now with timeline diagram support.

Cypress 12.6

? Articles & Tutorials

Use a MutationObserver to Handle DOM Nodes that Don’t Exist Yet — Comparing the effectiveness of the MutationObserver API with the conventional method of constantly checking for the creation of nodes.

Alex MacArthur

Well-Known Symbols in JavaScript — Hemanth, a TC39 delegate, shows off 14 symbols and where they can come in useful.

Hemanth HM

? Monitor and Optimize Website Speed to Rank Higher in Google — Monitor Google’s Core Web Vitals and optimize performance using in-depth reports built for developers. Improve SEO & UX.

DebugBear sponsor

Why to Use Maps More and Objects Less — A journey down a performance rabbit hole.

Steve Sewell

Adopting React in the Early Days — A personal history lesson providing context around React’s evolution. While React might be an obvious, even safe, choice now, that wasn’t always true.

Sébastien Lorber

An Animated Flythrough with Theatre.js and React Three Fiber — How to fly through a 3D scene using the Theatre.js JavaScript animation library and the React Three Fiber 3D renderer. This is the sort of thing that used to be Very Difficult™ but is now relatively trivial.

Andrew Prifer (Codrops)

How to Change the Tab Bar Color Dynamically with JavaScript

Amit Merchant

Is Deno Ready for Primetime? One Dev’s Opinion

Max Countryman

Using Playwright to Monitor Third-Party Resources That Could Impact User Experience

Stefan Judis

? Code & Tools

Dependency Cruiser: Validate and Visualize JavaScript Dependencies — If you want a look at the output, there’s a whole page of graphs for popular, real world projects including Chalk, Yarn, and React.

Sander Verweij

Devalue: Like JSON.stringify, But..“Gets the job done when JSON.stringify can’t.” Namely, it can handle cyclical and repeated references, regular expressions, Map and Set, custom types, and more.

Rich Harris

? JavaScript Scratchpad for VS Code (2m+ Downloads) — Get Quokka.js ‘Community’ for free: #1 tool for exploring/testing JavaScript with edit-continue experience to see realtime execution and runtime values.

Wallaby.js sponsor

NodeGUI: Build Native Cross-Platform Desktop Apps with Node.js — Unlike Electron which leans upon webviews and HTML, NodeGui uses a Qt based approach. This week’s 0.58.0 release is the first stable release based on Qt 6 and offering high DPI support.

NodeGui

DOMPurify 3.0: Fast, Tolerant XSS Sanitizer for HTML and SVG — A project that’s nine years old today but still actively developed. Supports all modern browsers (IE support was only just dropped) and is heavily tested. There’s a live demo here.

Cure53

Pythagora: Generate Express Integration Tests by Recording Activity — This is a neat idea still in its early stages. Add a line of code after setting up an Express.js app and this will capture app usage and generate integration tests based on the interactions. (▶️ Screencast demo.)

zvone187 and LeonOstrez

Try Stream’s Free Trial of SDKs for In-App Chat

Stream sponsor

grep.app: Search Code Across a Half Million GitHub Repos — A code search engine that lets you use regexes or syntax in your search. Considering what it is, it’s pretty fast and has an extensive index (over half a million public repos from GitHub, allegedly).

grep.app

tsParticles: Particles, Confetti and Fireworks for Your Pages — Create customizable particle related effects for use on the Web. Uses the regular 2D canvas for broad support.

Matteo Bruni

? Jobs

Software Engineer — Join our happy team. Stimulus is a social platform started by Sticker Mule to show what’s possible if your mission is to increase human happiness.

Stimulus

Find JavaScript Jobs with Hired — Hired makes job hunting easy-instead of chasing recruiters, companies approach you with salary details up front. Create a free profile now.

Hired

QUICK RELEASES:

Minimatch 6.2
↳ Glob matcher library, as used in npm.
    minimatch(“bar.foo”, “*.foo”)

React Accordion 1.2
↳ Unstyled WAI-ARIA-compliant accordion library.

ScrollTrigger 1.0.6
↳ Have your page react to scroll changes.

VeeValidate 4.7.4
↳ Popular Vue.js form library

Express Admin 2.0
↳ Admin interface for data in MySQL/Postgres/SQLite.

Execa 7.0
↳ Improved process execution from Node.js.

React Tooltip 5.8

Flatlogic Admin Templates banner

Vue Material Admin Update

Right after we have updated React Material Admin we also do the same with Vue Material Admin.

What products are affected by the update?

The update was released on 3 products:

Vue Material Admin Full
Vue Material Template Node.js
Vue Material Laravel Template

What has changed?

The main changes are in updated dependencies. We also updated the version of Vuetify as the Vue Material Admin based on it. So here is the list of main updates:

✅ amcharts/amcharts4: 4.10.22 -> 4.10.25
✅ amcharts/amcharts4-geodata: 4.1.22 -> 4.1.23
✅apexcharts: 3.29.0 -> 3.35.3
✅ axios: 0.23.0 -> 0.27.2
✅ core-js: 3.19.0 -> 3.22.7
✅ moment: 2.29.1 -> 2.29.3
✅ vue-router: 3.5.2 -> 3.5.3
✅ vue-apexcharts: 1.6.0 -> 1.6.1
✅ vuetify: 2.5.10 -> 2.6.6

So the Vue Material Admin is up-to-date and we would be really happy if you choose it for your future projects. You don’t need to spend your time updating all those technologies by yourself, so you can focus on developing business features.

Moving forward and Summing Up

We will be constantly updating all of our Vue templates as new libraries will release. And for sure sometime release one of our templates on Vue 3.

For the rest of our Vue templates, check our marketplace. If you face any difficulties setting up this or that template or admin dashboard, please feel free to leave us a message on our forumTwitter or Facebook. We will respond to your inquiry as quickly as possible!

Happy coding!

The post Vue Material Admin Update appeared first on Flatlogic Blog.Flatlogic Admin Templates banner

React Material Admin Full Update

As Material UI and React continue to grow and develop it has become clear that React Material Admin can’t live with the outdated versions of those libraries.

What products are affected by the update?

Currently, the updates were released on 2 products:

React Material Admin Full
React Material UI Admin Node.js

What has changed?

The main change is that now those templates are now using React 17 and Material UI 5, previously it was 16 and 4 versions accordingly.

And also we made several minor changes that make this admin dashboard template up-to-date.

Fullcalendar was updated to the 5.11 version
Added Datefns as datepicker library
Updated Apexcharts to version 3.35
Updated Formik library to the latest stable version
Mui-datatables library was updated to version 4
We have added Redux for management CRUD functions and authorization

As a result, the speed and usability of the React Material Admin template increased. Additionally, you don’t need to spend your time updating all those technologies by yourself, so you can focus on developing business features.

Moving forward and Summing Up

The ecosystem of our templates will be constantly updating. Next in line are Vue Material Admin and Angular Material Admin. Additionally, we are working on integrating some of the existing UI components from React Material Admin to the Flatlogic Platform generated react app.

For the rest of our React templates, check our marketplace. If you face any difficulties setting up this or that template or admin dashboard, please feel free to leave us a message on our forumTwitter or Facebook. We will respond to your inquiry as quickly as possible!

Happy developing!

The post React Material Admin Full Update appeared first on Flatlogic Blog.Flatlogic Admin Templates banner

One Weird Trick to Try @parcel/css on CodePen

Ideally, we’d just offer @parcel/css as a CSS processor choice right in our editors. We could absolutely do that, but we’re smack in the middle of a bunch of next-gen CodePen stuff, and we’re keeping our efforts focused there. Never fear, interesting new processors like this will be there along with it. But this CSS processor caught my eye especially because it’s a very fresh, modern, and interesting take on CSS processing. It handles vendor prefixing on its own (something you might otherwise use Autoprefixer for), it handles “syntax lowering” (love that term) for future-syntax CSS (like you’d use postcss-preset-env for), offers scoping, and even has its own built-in minifier, while being super fast. Nice!

So what if you do wanna try it on CodePen? Well, it’s actually possible because they have cleverly released the processor with a Wasm option, not just a backend-language-only thing. So here’s the plan:

Load the processor in the browser as a script (go Wasm go!)
Pull the CSS from the current Pen
Pass that CSS to the in-browser processor we just loaded
Get the transformed CSS
Replace the CSS in the preview with the transformed CSS

Check it:

CodePen Embed Fallback

The post One Weird Trick to Try @parcel/css on CodePen appeared first on CodePen Blog.Flatlogic Admin Templates banner

Caching NextJS Apps with Serverless Redis using Upstash

The modern application we build today is sophisticated. Every time a user loads a webpage, their browser needs to download the bulk of data in order to display that page. A website may consist of millions of data and serve hundreds of API calls. For the data to move smoothly with zero delays between server and client we can follow many strategies. We, developers want our app to deliver the best user experience possible, to achieve this we can employ a variety of techniques available.

There are a number of ways we can address this situation. It would be the best optimization if we could apply techniques that can reduce the amount of latency to perform read/write operations on the database. One of the most popular ways to optimize our API calls is by implementing Caching mechanism.

What is Caching?

Caching is the process of storing copies of files in a cache, or temporary storage location so that they can be accessed more quickly. Technically, a cache is any temporary storage location for copies of files or data, but the term is often used in reference to Internet technologies.

By Cloudflare.com

The most common example of caching we can see is the browser cache, which stores frequently accessed website resources locally so that it does not have to retrieve them over the network each time they are needed. Caching can boost the performance bottleneck of our web applications. When mostly dealing with heavy network traffic and large API calls optimization this technique can be one of the best options for our performance optimization.

Redis: Caching in Server-side

When we talk about caching in servers, one of the top pioneers of caching built-in databases is Redis. Redis (for REmote DIctionary Server) is an open-source NoSQL in-memory key-value data store. One of the best things about Redis is that we can persist data in a database that can continuously store them unless we delete or flush it manually. It is an in-memory database, its data access operations are faster than any other disk-based database, which eventually makes Redis the best choice for caching.

Redis can also be used as a primary database if needed. With the help of Redis, we can call to access and reaccessed as many times as needed without running the database query again. Depending on the Redis cache setup, this can stay in memory for a few hours, a few minutes, or longer. We even can set an expiration time for our caching which we will implement in our demo application.

Redis is able to handle huge amounts of data in real-time, making use of its in-memory data storage capabilities to help support highly responsive database constructs. Caching with Redis allows for fewer database accesses, which helps to reduce the amount of traffic and instances required even achieving a sub-millisecond of latency.

We will implement Redis in our Next application and see the performance gain we can achieve.

Let’s dive into it.

Initializing our Project

Before we begin I assume you have Node installed on your machine so that you can follow along with the steps involved. We will use Next for our project because it helps us write front-end and back-end logic with no configuration needed. We will create a starter project with the following command:

$ npx [email protected]typescript

After the command, give the project the desired name. After everything is done and the project is made for us we can add the dependencies we need to work on in this demo application.

$ npm i ioredis @chakra-ui/core @emotion/core @emotion/styled emotion-theming
$ npm i –save-dev @types/node @types/ioredis

The command above is all the dependencies we will deal with in this project. We will be making the use of ioredis to communicate with our Redis database and style things up with ChakraUI.

As we are using typescript for our project. We will also need to install the typescript version of the node and ioredis which we did in the second command as our local dev dependencies.

Setting up Redis with Upstash

We definitely need to connect our application with Redis. You can use Redis locally and connect to it from your application or use a Redis cloud instance. For this project demo, we will be using Upstash Redis.

Upstash is a serverless database for Redis, with servers/instances, you pay per hour or a fixed price. With Serverless, you pay per request. This means we are not charged when the database is not in use. Upstash configures and manages the database for you.

Head on to Upstash official website and start with an easy free plan. For our demo purpose, we don’t need to pay. Visit the Upstash console after creating your new account and create a new Redis serverless database with Upstash.

You can find the example of the connection string used ioredis in the Upstash dashboard. Copy the blue overlay URL. We will use this connection string to connect to the serverless Redis instance provided in with free tire by Upstash.

import Redis from “ioredis”;
export const redisConnect = new Redis(process.env.REDIS_URL);

In the snippet above we connected our app with the database. We can now use our Redis server instance provided by Upstash inside or our App.

Populating static data

The application we are building might not be an exact use case but, we actually want to see the implementation of caching performance Redis can make to our Application and know how it’s done.

Here we are making a Pokemon application where users can select a list of Pokemon and choose to see the details of Pokemon. We will implement caching to the visited Pokemon. In other words, if users visit the same Pokemon twice they will receive the cached result.

Let’s populate some data inside of our Pokemon options.

export const getStaticProps: GetStaticProps = async () => {
const res = await fetch(
‘https://pokeapi.co/api/v2/pokemon?limit=200&offset=200’
);
const { results }: GetPokemonResults = await res.json();

return {
props: {
pokemons: results,
},
};
};

We are making a call to our endpoint to fetch all the names of Pokemon. The GetStaticProps help us to fetch data at build time. The getStaticProps()function gives props needed for the component Home to render the pages that are generated at build time, not at runtime, and are static.

const Home: NextPage<{ pokemons: Pokemons[] }> = ({ pokemons }) => {
const [selectedPokemon, setSelectedPokemon] = useState<string>(”);
const toast = useToast();
const router = useRouter();

const handelSelect = (e: any) => {
setSelectedPokemon(e.target.value);
};

const searchPokemon = () => {
if (selectedPokemon === ”)
return toast({
title: ‘No pokemon selected’,
description: ‘You need to select a pokemon to search.’,
status: ‘error’,
duration: 3000,
isClosable: true,
});
router.push(`/details/${selectedPokemon}`);
};

return (
<div className={styles.container}>
<main className={styles.main}>
<Box my=”10″>
<FormControl>
<Select
id=”country”
placeholder={
selectedPokemon ? selectedPokemon : ‘Select a pokemon’
}
onChange={handelSelect}
>
{pokemons.map((pokemon, index) => {
return <option key={index}>{pokemon.name}</option>;
})}
</Select>
<Button
colorScheme=”teal”
size=”md”
ml=”3″
onClick={searchPokemon}
>
Search
</Button>
</FormControl>
</Box>
</main>
</div>
);
};

We have successfully populated some static data inside our dropdown to select some Pokemon. Let’s implement a page redirect to a dynamic route when we select a Pokemon name and click the search button.

Adding dynamic page

Creating a dynamic page inside of Next is simple as it has a folder structure provided, which we can leverage to add our dynamic Routes. Let’s create a detailed page for our Pokemon.

const PokemonDetail: NextPage<{ info: PokemonDetailResults }> = ({ info }) => {
return (
<div>
// map our data here
</div>
);
};

export const getServerSideProps: GetServerSideProps = async (context) => {
const { id } = context.query;
const name = id as string;
const data = await fetch(`https://pokeapi.co/api/v2/pokemon/${name}`);
const response: PokemonDetailResults = await data.json();

return {
props: {
info: response,
},
};
};

We made the use of getServerSideProps we are making the use of Server-Side-Rendering provided by Next which will help us to pre-render the page on each request using the data returned by getServerSideProps. This comes in handy when we want to fetch data that changes often and have the page updated to show the most current data. After receiving data we are mapping it over to display it on the screen.

Until now we really have not implemented caching mechanism into our project. Each time the user visits the page we are hitting the API endpoint and sending them back the data they requested for. Let’s move ahead and implement caching into our application.

Caching data

To implement caching in the first place we want to read our Redis database. As discussed Redis stores its data as key-value pairs. We will find whether the key is stored in Redis or not and feed the client with the respective data needed. For this to achieve we will create a function that reads Redis for the key client is requesting.

export const fetchCache = async <T>(key: string, fetchData: () => Promise<T>) => {
const cachedData = await getKey(key);
if (cachedData)return cachedData
return setValue(key, fetchData);
}

When we will know the client is requesting data they have not visited yet we will provide them a copy of data from the server and also behind the scene make a copy inside our Redis database. So, that we can serve data fast through Redis in the next request.

We will write a function where it takes in a parameter of key and if the key exists in the database it will return us parsed value to the client.

const getKey = async <T>(key: string): Promise<T | null> => {
const result = await redisConnect.get(key);
if (result) return JSON.parse(result);
return null;
}

We also need a function where it takes in a key and set the new values alongside with the keys inside our database only if we don’t have that key stored inside of Redis.

const setValue = async <T>(key: string, fetchData: () => Promise<T>): Promise<T> => {
const setValue = await fetchData();
await redisConnect.set(key, JSON.stringify(setValue));
return setValue;
}

Until now we have written everything we need to implement Caching. We will just need is to invoke the function in our dynamic pages. Inside of our [id].tsx we will make a minor tweak where we can invoke an API call only if we don’t have the requested key in Redis.

For this to happen we will need to pass a function as a prop to our fetchCache function.

export const getServerSideProps: GetServerSideProps = async (context) => {
const { id } = context.query;
const name = id as string;

const fetchData = async () => {
const data = await fetch(`https://pokeapi.co/api/v2/pokemon/${name}`);
const response: PokemonDetailResults = await data.json();
return response;
};

const cachedData = await fetchCache(name, fetchData);

return {
props: {
info: cachedData,
},
};
};

We added some tweaks to our code we wrote before. We imported and made the use of fetchCache functions inside of the dynamic page. This function will take in function as a prop and do the checking for key respectively.

Adding expiry

The expiration policy employed by a cache is another factor that helps determine how long a cached item is retained. The expiration policy is usually assigned to the object when it is added to the cache. This can also be customized according to the type of object that’s being cached. A common strategy involves assigning an absolute time of expiration to each object when it is added to the cache. Once that time passes, the item is removed from the cache accordingly.

Let’s also use the caching expiration feature of Redis in our Application. To implement this we just need to add a parameter to our fetchCache function.

const cachedData = await fetchCache(name, fetchData, 60 * 60 * 24);
return {
props: {
info: cachedData,
},
};

export const fetchCache = async (key: string, fetchData: () => Promise<unknown>, expiresIn: number) => {
const cachedData = await getKey(key);
if (cachedData) return cachedData
return setValue(key, fetchData, expiresIn);
}

const setValue = async <T>(key: string, fetchData: () => Promise<T>, expiresIn: number): Promise<T> => {
const setValue = await fetchData();
await redisConnect.set(key, JSON.stringify(setValue), “EX”, expiresIn);
return setValue;
}

For each key that is stored in our Redis database, we have added an expiry time of one day. When the set amount of time elapses, Redis will automatically get rid of the object from the cache so that it may be refreshed by calling the API again. This really helps when we want to feed the client with the updated fresh data every time they call an API.

Performance testing

After all of all these efforts we did which is all for our App performance and optimization. Let’s take a look at our application performance.

This might not be a suitable performance testing for small application. But app serving thousands of API calls with big data set can see a big advantage.

I will make use of the perf_hooks module to assist in measuring the time for our Next lambda to complete an invocation. This is not really provided by Next instead it’s imported from Node. With these APIs, you can measure the time it takes individual dependencies to load, how long your app takes to initially start, and even how long individual web service API calls take. This allows you to make more informed decisions on the efficiency of specific code blocks or even algorithms.

import { performance } from “perf_hooks”;

const startPerfTimer = (): number => {
return performance.now();
}

const endPerfTimer = (): number => {
return performance.now();
}

const calculatePerformance = (startTime: number, endTime: number): void => {
console.log(`Response took ${endTime – startTime} milliseconds`);
}

This may be overkill, to create a function for a line of code but we basically can reuse this function in our application when needed. We will add these function calls to our application and see the results millisecond(ms) of latency, it can impact our app performance overall.

In the above screenshot, we can see the millisecond of improvements in fetching the response. This can be a small improvement in the small application we have built. But, this may be a huge time and performance boost, especially working with large datasets.

Conclusion

Data-heavy applications do need caching operations to improve the response time and even reduce the cost of data volume and bandwidth. With the help of Redis, we can deduct the expensive operation database operations, third-party API calls, and server to server requests by duplicating a copy of the previous requests in our Redis instance.

There might be some cases, we might need to delegate caching to other applications or microservices or any form of key-value storage system that allows us to store and use when we need it. We chose Redis since it is open source and very popular in the industry. Redis’s other cool features include data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, HyperLogLogs, and many more.

I highly recommend you visit the Redis documentation here to gain a depth understanding of other features provided out of the box. Now we can go forth and use Redis to cache frequently queried data in our applications and gain a considerable performance boost.

Please find the code repository here.

Happy coding!

The post Caching NextJS Apps with Serverless Redis using Upstash appeared first on Flatlogic Blog.Flatlogic Admin Templates banner

6 React Project Ideas to Help You Learn by Doing (Updated 2022)

Why do you need these React project ideas?

A list of React project ideas

Personal Productivity App

YouTube Comments Analyst

Weather App

Messenger Aggregator

Personal Expense Tracker

Recommendation App

Conclusion
Bonus
Creating a React App the quick way with Flatlogic

Everyone faced the dilemma of what app you should develop next to make progress in learning React. The project must be complex enough to make you think and google, but not too hard so you don’t feel overwhelming. And you are looking for a great article where you can find a brilliant React project ideas for your next project that just fits your skills.

Well… If it looks familiar, then that article can’t help you=)

This article doesn’t offer you to learn new skills, practice design, research new ways to provide great user experience, or something else… It’s about the challenge!

Why do you need these React project ideas?

The ideas in the article are supposed to push you beyond your limits, to force you to think furiously, to blow your mind with problems you are going to face. And much more…

That top is not about simple components and apps like quizzes, books apps, or note-taking up. Moreover, it isn’t necessary to take that challenge if you have just finished tutorials and started working on your first React project idea. It’s expected that you have already known the basic foundation of React Native development and have taken part in the development of some complex apps.

But don’t hurry to close the article if you are a new guy in programming! The ideas you find here are entertaining and interesting, and maybe someday when you get a lot of experience and acquire new skills you will ask yourself a question “What else can I develop?”. Then you will remember that you read that article with some fascinating ideas, then one of the ideas will come to your mind and bingo! You will understand what your next app will be about!     

Enjoy reading!

A list of React project ideas

Personal Productivity App

Image source: https://habitica.com/static/features

Everyone desires to be productive, achieve his dreams, be an iron-man / attractive girl, be disciplined, give up bad habits, and just be listed in Forbes top richest people. Let’s help them.

We don’t offer to invent a new productivity method since there is a bunch of them that already exist (for example, check this article). Also, we don’t expect you to create a holistic motivational system, like gamification in Habitica.  Our task is to make a calendar-based productivity app with reports, reminders, dashboard for tasks and habits. Let’s clarify all these basic components.

Calendar-based app implies that the users are supposed to plan their days, so the app should give them that opportunity with a calendar where they can set the time and day where they are going to accomplish tasks or devote time to acquire a new habit. The app has to remind users about upcoming events and what they have planned for today. You also should include instruments like to-do lists or dashboards in the app with different statuses of tasks like “to do today, tomorrow, this week, someday”. Next thing in the to-do list (your to-do list, not in the app) is to make reports about tasks accomplishment with different periods (a day, week, month), so your users become aware of their progress. After developing all these features the most interesting part of the app goes, check the list below.  

Ways to comprehend:

Add website and app blocker. This helps potential users not to be distracted by social media or notifications from other apps.
Make the phone goes into the silent mode when a user works with the app and gives users an ability to set the time or set conditions when the mode should automatically be enabled.

YouTube Comments Analyst

Image source: https://developers.google.com/youtube/v3

If you have a lot of followers on YouTube, you know how hard it is to understand what the mood of those one hundred thousand comments is. Are people happy watching your videos or they are bored?  Do you make an impact on people with your work and creativity? What followers wanted to see?

You can develop an app that analyses the comments for you and answers all your questions. The app is based on a dictionary of words with some values assigned to them. You can set different types of values, but let’s start with just two: positive value for words like “Awesome” and “Great” and negative value for words like “Bad”, “Useless”, “Boring”.  Then the app collects the comments (use YouTube data API) and calculates the total score.

Once it’s done, think about UI for the app. We need a field to input link to YouTube video, a pie chart to display total like and dislike amount, a histogram to plot the results for different sentiment groups of comments. 

 Ways to comprehend:

Add the history of videos you have checked and monitor the changes in sentiment over time.
Also, you can go further and try to calculate the impact on people via comments, but it’s harder since you need to add values not only to words but to word combinations too. (as an example, “that video inspired me to chase my dream!”)
Dive deep into the analysis and add the option to examine certain groups of comments. Why negative comments are negative? Do they have something in common? What are the most liked comments about? Are they good jokes or greeting to the author that other people share?

Weather App

Image source: https://openweathermap.org/city/3117735

A great React project idea is to make an app that displays a weekly weather forecast. The core requirement for the app is usable and clear user interface: users must get desired information (the weather forecast) just when they open the app. Users are more interested in two questions: what should I wear today and should I take an umbrella? So, it’s good to start just with temperature and precipitation. Drop the information about wind speed, cloud cover, the time of sunset and sunrise (of course with cool animation that definitely will take a few hours of development), etc. Let’s say you get it and now you need to show the weather for today. How?

The basic element to display weather forecast here is a day weather card. All cards with daily forecasts must be structured and well organized, so prepare to unleash your potential as an expert designer or just ask your friend to prepare a mock-up for you.

The second necessary feature is accuracy, so make sure that you pick a well-known and checked online service to forecast the weather. We advise to use the most popular websites like https://weather.com/, and more trusted API sources (like this).

You can guess that it’s time to add information about pressure, cloudiness, wind speed, etc. Well, we don’t think so. 

When the previous two steps are completed, think about UX and what features users may need. It’s good to start with adding the ability for users to change the period for days display: today, current week, 7 days, 10 days, 15 days, 30 days. Then make a report of hourly temperature changes and the chance of precipitation. Also, add the function of precise positioning and the ability to select several regions/cities to monitor. When everything is done and tested you get an informative app about the weather forecast for various periods in different regions. Maybe now it’s time to show additional information for the daily weather we mentioned above? Well, no, you still have a work to do, look through the list below.

Ways to comprehend:

Use graphic libraries to display daily changes in the weather or add a graphic representation of week temperatures.
Add a dynamic built-in map that displays precipitation over the time until now.

Running in background with push notifications about the rain, snow, high/low temperatures, or fog will be a great improvement for the app.
How about the idea to make the app function on smartwatches? (and then you should feel free to publish the app on the Google Play and App store)
All right, fine, you can display pressure, wind speed, and whatever you want.

Messenger Aggregator

Image source: https://pixabay.com/

It can be hard to manage all chats and messaging services, like Skype, sack, What’s up, Viber, telegram, Google hangouts, etc. Try to build a universal messenger that combines them all. The must-be functionality: support of as many messengers and chats as you are able to set, the UI that allows users to switch between them quickly, support of push notifications for mobile and desktop, multilingual, ensuring the privacy of personal messages. As we have mentioned, there are a lot of variant messaging services. First, provide support for 5 messengers in most demand in your region and meet all requirements above. After that look through the list below.    

Ways to comprehend:

Add the ability to manage multiple accounts in any messenger. This function can be very helpful for businesses and very challenging for you: how many messengers can you set up with multiple accounts?
Expand the functionality with synchronization of services across all devices you log in on so you don’t need to add it manually every time on a new device.
Allow your app to set rules for prioritization of the notifications by putting them on the top.
Just add MORE messaging services and chats!       

Personal Expense Tracker and Analyst (Using Big Data)

Image souce: https://www.mint.com/how-mint-works

Forget the second part about big data for a while and concentrate on building the basis of the expense app. The app should allow users to track their expenses and to analyze it. So, the core functionality here is adding the records of the cash flow. Expenses and income must be divided by categories and users should be able to create custom ones. To analyze cash flow the app creates charts for different periods with the ability to display expenses and income by categories. 

After that, the most fascinating part of the challenge goes: try to provide insight into users’ spending habits using all records from the previous periods (it takes time to create them first) with the help of artificial intelligence and big data. Teach it how to make predictions about future expenses based on previous periods, reveal budget lines that take extra money from users, accumulate as much information as possible, and create tips for reports, so even users with no financial background can understand where they spend their money.

Ways to comprehend:

Set up an integration with bank accounts and credit/debits cards.

Add some planning with budgeting. And more reports as a result. It’s not enough just to track your expenses, it’s necessary to learn how to control them.   

Comparison is a good tool to show alternative ways of spending money (for example you spend as much money on the bun as the cost of monthly gym membership).

Recommendation App

Image source: https://thespoke.co/

The concept is to provide users with movie recommendations based on their preferences. The fundamental features are rating, cards with pictures, a large database, nice-looking design, maybe swipe option. You don’t need to build a media player for various video formats. Your focus must be on the development of a clear user interface design and engaging interactions. The app should capture users’ attention and motivate them to provide necessary information about their interests so the recommendations would be accurate.    

Every way to comprehend implies a new branch of recommendations for different aspects of our lives. Implementing them all means that you have developed a universal recommendation app. Every branch requires the expansion of date base and new functionality. The list of branches you can find below:

Ways to comprehend:

Add dish recommendations.
Let users discover new books.
Expand the database with musical artists and help users to find a new sound.
Integrate the app with training services with online courses.

Challenge yourself and bring to life React project ideas

Knowledge is of no value unless you put it into practice.

So you’ve spent dozens of hours learning a new technology, in this case React. However, only practice will provide an opportunity not only to consolidate knowledge, and also it can add impressive projects to your portfolio. Any employer wants to see some projects done, despite the fact that you may not have any work experience yet.

In this case, it is important to decide on the technology stack. There is simply no time and effort to study two or three alternatives at once.

Therefore, we decided to help determine the choice of specialization as a bonus. You can often find information about the advantages of a particular framework or library. We will write about possible unpleasant surprises that may await when implementing the aforementioned React project ideas.

Together we are strong, but separately we will perish. This aphorism best describes the ambiguous situation with this library. On the one hand, React has huge community, tens of thousands of specialists from different countries.  Open source and the ability to create new modules, in addition to its advantages, has disadvantages in the form of incomplete guidance, lack of support and inability to find solutions. Even the official React site still provides examples of class components, although the community and the library itself have chosen the functional components and hooks course.

Looking at Stack Overflow, which has over 255 thousands React questions, some thoughts also pop up. On the one hand, you don’t have to worry about the lack of an answer to your question, and on the other hand, you can doubt the quality of the library. After all, if something works well, then should there be any questions?

React is an opinionless library; this means that she has no opinion on how to solve problems that touch on all aspects. So it is up to you and your team to come up with an opinion on what to do with a particular react project idea, and especially what other libraries you want to use. Of course, you will be using third party libraries because you don’t want to reinvent the wheel. And there are many different options in React.

There are many similar react project ideas, but you won’t fund two projects with the same dependencies, project structure, and guidelines. This means that knowledge cannot be transferred from project to project, as it can in the case of Angular or Vue.

Thanks for reading.

Bonus!

We’ve listed 6 easy variants to learn React by doing. Now we’ll offer you two more React project ideas. One is the most beginner-friendly option, and the other a more challenging option. Also, we’ll offer an easier path you’ll want to follow if you’re done with challenges for the day;)

Calculator App

For those who are just starting out with React and don’t have too much time to learn the deep intricacies. A calculator app is about as basic as it gets. The functionality and the interface are easy to adjust, and the app’s operation is easy enough to check. Does it calculate properly? Voila! You’ve done a great job.

The Value of this Challenge

This won’t challenge experienced developers. But those with no expertise but a strong desire to learn by doing would benefit from starting small. A minimal challenge provides an intermediate checkpoint where you can evaluate your progress and get that small bit of gratification that will help motivate you to achieve more.

e-Commerce App

Apps for eCommerce are an infinitely scalable challenge. Based on your experience and spare time, you can make a very basic or a more complex solution. This will require some back-end and database-building skills apart from React mastery. A simple React eCommerce App may only have a primitive database with two or three parameters of each entry and a simple input procedure. As your experience grows, you can introduce more data relationships and inner mechanisms. Each layer of parameters, features, and pages brings out new opportunities for creating yet more features based on those that are already there.

The value of this challenge

eCommerce Apps rarely display unique functionality. The real challenge here is navigating the architecture of a complex, multi-storied App and creating an end product that’s easy enough to navigate for the users. Additionally, eCommerce Apps are a frequent use case for React, and you’d be amiss to skip it in your front-end practice.

Creating a React App the quick way with Flatlogic

As promised, a quicker and easier way to create a React App. This way has many uses but fits eCommerce especially well. The Flatlogic Platform lets you combine parts and elements to create an App of your own. Next up are the steps necessary to do it.

#1: Name the project

Name your project. This way the project will be easier to address and find in case you start another one.

#2: Choose stack

An App’s stack consists of technologies its front-end, back-end, and database run on. In this example, we’ll pick React but any combination will work.

#3: Choose the design

The Platform offers several (we keep adding new options or merging existing ones, so the number might change) design schemes. Take a look at each one and decide which one feels the most natural to you.

#4: Choose the schema

Define the parameters of your database. Fields, columns, types of data, and the way the App processes entries – all of that must be defined. Or you could save some time and stick with one of the presets. They’re tailored to popular demands and at least one of them will likely fit.

#5: Review and generate

Check your choices, see if everything is fine. Choose “Connect GIT Repository” if you want to. Hit “Finish”.

Flatlogic Platform will compile for a couple of minutes and introduce you to your App. Deploy it, host it locally, or push it to GitHub, and make good use of it! Happy developing!

You might also like these articles:

Top 5 Free Awesome React.js Material-UI Admin Dashboard Templates

13 Bootstrap Date Pickers Examples
Top 19+ Remarkable JavaScript Data Table Libraries and Plugins

The post 6 React Project Ideas to Help You Learn by Doing (Updated 2022) appeared first on Flatlogic Blog.Flatlogic Admin Templates banner

What is Material UI

Introduction

Material-UI (MUI) is a CSS framework that provides React components out-of-the-box and follows Google’s Material Design launched in 2014. MUI makes it possible to use different components to create a UI for a company’s web and mobile apps. Google uses Material Design to guarantee that no matter how users interact with the products they use, they will have a consistent experience. Material Design includes guidelines for typography, grid, space, scale, color, images, etc. And it also allows designers to build deliberate designs with hierarchy, meaning, and a focus on results.

The MUI library for React has over 76k stars on GitHub and is one of the most improved UI libraries. You can build an incredibly stylish application in a short amount of time with pre-styled components, as well as tune and expand these components according to your needs. It is based on Leaner Style Sheets (LESS), a CSS development extension.

You can also install the MUI into your application using yarn:

yarn add @material-ui/core

or npm:

npm i @material-ui/core

Why use Material UI?

Here are the reasons why developers prefer to integrate MUI into their applications:

Pre-designed UI components. MUI supplies multiple pre-designed components from which you easily approach and attach to your application, enabling an attractive, easy-to-use, and visually engaging design and rapid implementation. 

Material Design. Material Design is a well-thought-out design system that describes the value and use cases of components. With Material Design, for example, you can use the Material Icons, meaning choosing icons that match your design system.

Adjustable theme. MUI provides simple installation and adjustment themes to use and globally implement for all components available to you, making it a highly functional and dynamic experience. By doing so, the theme color of the component, information about the palette, and surface properties, and some other styles can be customized, meaning that all your components can be consistent.

Well-structured documentation. MUI has clearly understandable and well-structured documentation, which includes guides with code examples to practice with.

Widespread support. MUI has great support for fixing bugs and issues, due to its constantly updatable library. In small releases, for all issues found, the team provides fixes. And as a user, you can participate in influencing what additions to the library will be added in the future. The team sends a feedback survey to all library developers every year in order to fix any issues and make the Material UI more usable, also you can tweet them feedback on the official account: @MaterialUI.

Community. Here you can find basic links with support and examples of using the MUI.

Who uses Material UI and its integrations?

Node.js, React, Next.js, Emotion, and etc, represent some of the most popular tools that are integrated with Material-UI. About 214 companies use Material UI in their technology stacks, here are some of them:

UNIQLO
Medium
Scale
Frontend
Google
SkyQuest Tech Stack

How to create your Material UI React application using the Flatlogic Platform

There are two ways to build your application on the Flatlogic Platform: 

Create a simple and clear frontend application, generated by the CLI framework, 

or

Build a CRUD application with frontend+backend+database.  

Creating your CRUD application with Flatlogic

Step 1. Choosing the Tech Stack

In this step, you’re setting the name of your application and choosing the stack: Frontend, Backend, and Database.

Step 2. Choosing the Starter Template

In this step, you’re choosing the design of the web app. Here you can find the Material Template for your application.

Step 3. Schema Editor

In this part you will need to know which application you want to build, that is, CRM or E-commerce, also in this part you build a database schema i.e. tables and relationships between them.

If you are not familiar with database design and it is difficult for you to understand what tables are, we have prepared several ready-made example schemas of real-world apps that you can build your app upon modification:

E-commerce app;
Time tracking app;
Books store;
Chat (messaging) app;
Blog.

Afterwards, you can deploy your application and in a few minutes, you will get a fully functional CMS for your React Application with Material Design.

Suggested Articles:

What is Angular – Flatlogic Tech Glossary
What is Webpack – Flatlogic Tech Glossary
How to Create a Vue Application [Learn the Ropes!]

The post What is Material UI appeared first on Flatlogic Blog.Flatlogic Admin Templates banner

What is Angular

Introduction

Angular is a client-side open-source JavaScript-based front-end framework, which is used to build custom applications in HTML, CSS and Typescript. AngularJS was launched in 2009 by Misko Hevery and Adam Abrons as a project at Google.  It is a front-end JavaScript framework, which was developed to build web-based dynamic applications easier, due to its MVC (Model-View-Controller) feature. AngularJS is currently supported as a framework, although no longer being developed or updated.

Don’t confuse it with Angular (without JS) which is the term for Angular 2 and above (i.e. versions 2, 4, 5, 6, 7, 8, and now the latest version is 13) which was released in 2016. Angular 2, as it used to be known, demonstrated considerable differences from AngularJS, the main difference of which was its change in the template language.

One of the key features of Angular is that it uses TypeScript as a programming language. Alternatively, it is possible to create Angular applications using languages such as Dart or JavaScript. However, TypeScript is still the primary language. 

Angular has four main types of web app development:

PWAs (Progressive Web Apps)
UI animations
Web and mobile applications
Business web applications

Why use Angular

Angular is a quite popular framework for building web and mobile apps and can be the perfect framework for building large-scale, powerful and easy-to-serve web apps. So here is the list of reasons why you should use Angular:

Safety. Angular is a fairly trustworthy platform because it is supported by Google

Reduced development time. Angular relies on the current JavaScript virtual machine by transforming templates into code. Angular’s load time is also fast. 

Unit test friendly. Angular features two-way data binding of modules and components, which makes the code consistent and easy to understand for unit testing. Every unit of code is independently tested across the entire app building process, providing in-depth quality control.

Cross-platform. Angular-based PWAs can run on a variety of platforms, and the framework is widely used in native mobile apps. Previously, frontend developers used a cross-platform combo of Ionic with Angular. Nowadays, its most popular combo is with NativeScript.

Complex learning curve. Angular uses a much harder learning curve than other frameworks. To get started, you need to explore all aspects of the framework, such as RxJS (a reactive library for asynchronous development) and Typescript (used to increase maintainability and code support capabilities), not just basic JavaScript. 

Community. Angular has a great community and ecosystem which is actively supported. There is plenty of content on the framework like guides and videos, and lots of useful third-party tools as well.

With all the advantages of Angular, it is not a universal solution for absolutely every task, and that’s okay. Every technology is well suited to solve specific issues, and for some other tasks, other approaches will be more reasonable. It’s easy to use Angular to create a project, but it’s harder to understand if this solution is really good or if it’s worth using.

Who uses Angular

Let’s take a look at the list of cutting-edge companies that use Angular in their modern web application development pipeline:

Google
Gmail
PayPal
Forbes
Samsung
Microsoft Xbox
Deutsche Bank
The Guardian
Weather.com
Lego

How to create your Angular application using the Flatlogic Platform

There are two ways to build your application on the Flatlogic Platform: one-page application only with the frontend or the CRUD application with frontend, backend, database.  

Creating the CRUD application with Flatlogic

1 Step. Choosing the Tech Stack

Firstly, you should set the name of your application and choose the stack: Frontend, Backend, and Database.

2 Step. Choosing the Starter Template

Next, you’re choosing the design of your web application.

3 Step. Schema Editor

In this step you will need to know which application you want to build, that is, CRM or E-commerce, also in this part you build a database schema i.e. tables and relationships between them.

If you are not familiar with database design and it is difficult for you to understand what tables are, we have prepared several ready-made example schemas of real-world apps that you can build your app upon modification:

E-commerce app;
Time tracking app;
Books store;
Chat (messaging) app;
Blog.

Finally, you can make deployment of your application and in a few minutes, you will get a fully functional CMS for your Angular Application.

Creating a one-page application with Flatlogic 

You can create a frontend-only app with the Flatlogic Platform. This assumes you host the backend somewhere else or do not need it at all. To generate a one-page application you don’t need to enter anything in the terminal of your IDE, you just need to go to the page of creating an application on the Flatlogic website and make only 2 steps:

1 Step. Choosing the Tech Stack

In this step, you set the name of your application and choose the stack: Frontend as Angular, Backend as No-Backend.

2 Step. Choosing the Starter Template

In this step, you choose the design of the web app. Since this is a standard one-page application created using the CLI framework, it will have the design of a standard one-page Angular CLI application.

The final step is to deploy your app and in a few minutes, you will get a one-page Angular application, which you can further modify as you like.

Suggested articles:

What is React
What is PHP
What is Laravel

The post What is Angular appeared first on Flatlogic Blog.Flatlogic Admin Templates banner

Angular Server Side Rendering on Azure Static Web Apps

This post is about how implement Angular Server side rendering apps on Azure Static Web Apps. What is server-side rendering – A normal Angular application executes within the browser, rendering pages within the DOM in response to user actions. Angular Universal executes on the server, generating static application pages that later get bootstrapped on the consumer. This implies that the appliance usually renders additional quickly, giving users an opportunity to look at the appliance layout before it becomes totally interactive.

To get started, install the @nguniversal/express-engine package to your Angular application. You can do this by running the ng add @nguniversal/express-engine command. Once you execute this command, it will modify few files in your Angular application like this.

Now you can check the application by running npm run build:ssr and then npm run serve:ssr. It will build the app and then serve it in localhost:4000 address. You won’t see any difference when you browse the application. You can find more details about Angular Server side rendering, its pros and cons in the Angular Website.

Next lets push this app to Github, so that we can create a Static Web App for this. Before creating the project, I created a GitHub repo. After checking whether every thing is working expected, commit and push the changes to the GitHub repository. Next create a static web app in Azure Portal. Under deployment details, configure your GitHub repo and main branch. And in the Build details, choose Angular as the build presets. Change the output location from dist to dist/AngularSSRSWA/browser.

Click on the Review and Create button to review the configuration and create static web app. Once it is done, open your GitHub repository, and find the workflows directory in the root – it will be under the .github directory. Edit the yml file and add app_build_command with this npm run prerender.

You can find more details about the app_build_command here – Build configuration for Azure Static Web Apps)

Commit the changes – Azure will build the application and deploy it.

This way you will be able to deploy Angular Server side rendering / Angular universal apps to Azure Static Web Apps. Here are some resources which will help you to learn more about Static Web Apps.

Quickstart: Building your first static site with Azure Static Web Apps
Configure front-end frameworks and libraries with Azure Static Web Apps

Happy Programming 🙂Flatlogic Admin Templates banner