0
0
NextJSframework~20 mins

Edge runtime vs Node.js runtime in NextJS - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Edge vs Node.js Runtime Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Differences in API support between Edge and Node.js runtimes
Which of the following APIs is NOT supported in the Next.js Edge runtime but works in the Node.js runtime?
AThe Node.js 'fs' module for file system operations
BThe native Fetch API for HTTP requests
CWeb Crypto API for cryptographic functions
DURL and URLSearchParams for URL parsing
Attempts:
2 left
💡 Hint
Think about which APIs require access to the server's file system.
component_behavior
intermediate
2:00remaining
Behavior of environment variables in Edge vs Node.js runtimes
In Next.js, how do environment variables behave differently when using Edge runtime compared to Node.js runtime?
AEdge runtime inlines all environment variables at build time, unlike Node.js
BEdge runtime can dynamically read environment variables at runtime
CNode.js runtime does not support environment variables
DEdge runtime supports all environment variables at runtime like Node.js
Attempts:
2 left
💡 Hint
Consider when and how environment variables are injected in Edge runtime.
📝 Syntax
advanced
2:00remaining
Correct way to specify Edge runtime in Next.js API route
Which code snippet correctly configures a Next.js API route to use the Edge runtime?
A
export const config = { runtime: 'edge-runtime' };
export default function handler(req) { return new Response('Hello from Edge'); }
B
export const config = { runtime: 'server' };
export default function handler(req) { return new Response('Hello from Edge'); }
C
export const config = { runtime: 'edge' };
export default function handler(req) { return new Response('Hello from Edge'); }
D
export const config = { runtime: 'nodejs' };
export default function handler(req) { return new Response('Hello from Edge'); }
Attempts:
2 left
💡 Hint
Check the exact string used to specify Edge runtime in Next.js config.
state_output
advanced
2:00remaining
Output difference when using Node.js-only modules in Edge runtime
What happens if you import the 'crypto' module from Node.js in a Next.js Edge runtime API route and try to use it?
NextJS
import crypto from 'crypto';

export const config = { runtime: 'edge' };

export default function handler() {
  const id = crypto.randomUUID();
  return new Response(id);
}
AThrows a TypeError because 'randomUUID' is not a function
BThrows a ReferenceError because 'crypto' is undefined
CThe code runs and returns a UUID string
DThrows a runtime error because Node.js modules are not supported in Edge runtime
Attempts:
2 left
💡 Hint
Think about module compatibility in Edge runtime.
lifecycle
expert
2:00remaining
Impact of runtime choice on cold start latency in Next.js API routes
How does choosing Edge runtime over Node.js runtime affect cold start latency for Next.js API routes deployed on Vercel?
ANode.js runtime has lower cold start latency because it uses persistent server processes
BEdge runtime generally has lower cold start latency due to lightweight serverless environment
CBoth runtimes have identical cold start latency on Vercel
DEdge runtime has higher cold start latency because it compiles code on every request
Attempts:
2 left
💡 Hint
Consider how serverless environments differ in startup speed.