This example shows a simple Next.js page that displays an image from an external domain. The next.config.js file allows loading images from that domain and enables React strict mode for better checks.
Always configure external image domains in next.config.js to avoid errors.
Use environment variables to keep sensitive data like API keys safe.
React strict mode helps find bugs early but can cause double rendering in development.
Summary
Deployment configuration sets how your Next.js app behaves on servers.
It helps with security, performance, and connecting to external services.
Proper setup avoids errors and improves user experience.
Practice
(1/5)
1. Why is deployment configuration important in a Next.js application?
easy
A. It disables all security features by default.
B. It changes the app's color scheme automatically.
C. It only affects the app's local development environment.
D. It controls how the app runs on the server and connects to services.
Solution
Step 1: Understand deployment configuration role
Deployment configuration sets how the app behaves on the server, including connections and performance.
Step 2: Compare options
Only It controls how the app runs on the server and connects to services. correctly describes deployment configuration's purpose; others are unrelated or incorrect.
Final Answer:
It controls how the app runs on the server and connects to services. -> Option D
Quick Check:
Deployment config = server behavior control [OK]
Hint: Think where your app runs and what config controls there [OK]
Common Mistakes:
Confusing deployment config with UI settings
Assuming it only affects local development
Ignoring security and performance roles
2. Which of the following is the correct way to specify an environment variable in Next.js deployment?
easy
A. Set variables in next.config.js under env property.
B. Write variables directly inside a React component.
C. Use a CSS file to store environment variables.
D. Declare variables only in package.json scripts.
Solution
Step 1: Identify environment variable setup in Next.js
Next.js uses next.config.js with an env property to define environment variables for deployment.
Step 2: Eliminate incorrect options
Options A, C, and D do not follow Next.js patterns for environment variables.
Final Answer:
Set variables in next.config.js under env property. -> Option A
Quick Check:
Env vars in next.config.js = correct [OK]
Hint: Remember env vars go in next.config.js, not in components [OK]