Lesson 9 of 16 · 40 min suggested practice

Add an integration without exposing private API keys

Understand the browser/server boundary before adding email, AI, or other services to Resource Shelf.

By Ashley Kays · Reviewed November 19, 2026 · Independent learning guide

The answer: Private credentials belong in trusted server-side configuration, not browser code or downloadable examples. Add an integration only when it serves a clear task, validate its inputs, and check permissions before calling a private or paid service. The static version of Resource Shelf needs no API key.

Name the benefit and the data being sent

A useful optional feature might let an editor draft a short resource summary from text they supplied. Write down exactly what information leaves the app, which provider receives it, and what the user expects back. Do not silently send saved lists or private account data to a third party.

Keep the first catalogue functional without this feature. If a provider is unavailable or credits run out, visitors should still be able to browse and download existing resources. An optional integration should not become a hidden dependency of the core experience.

Distinguish public configuration from secrets

A public analytics measurement ID or a publishable database key has a different role from a secret API credential or service-role key. Browser code is visible to visitors, including values placed in frontend environment variables. A private key must not be shipped there.

Lovable provides secure secret input and project secret storage for server functions. Use the intended secure form when a service requires a credential. Keep credentials out of chat examples, screenshots, source files, CSV practice data, and the free toolkit. Document the secret's purpose without recording its value.

Protect the server action

For an editor-only summary action, the server must verify that the caller is allowed to edit resources before making the provider request. A disabled frontend button is insufficient. Validate the supplied text, limit its size, and return only the information the interface needs.

Handle repeated clicks, slow responses, rejected credentials, provider limits, and unexpected output. Show progress and a useful retry option without revealing internal secrets. If the integration creates a cost, make that action intentional and add an appropriate usage limit rather than letting anonymous visitors trigger it freely.

Test the boundary, not just the happy path

Check an authorized request, an unauthenticated request, a normal user attempting the editor action, empty input, overly long input, and a provider failure. Inspect the browser's response and built files for accidental credential exposure. Use synthetic content for the exercise.

If a call works only from the preview, compare production configuration and permissions. If an integration fails, investigate the server error and provider response instead of moving the key into the browser to make the request easier. Keep the feature off until its access and failure behavior are understood.

Try this focused prompt.

Plan an optional editor-only resource-summary helper for Resource Shelf. Keep the public library working without it. Send only text the authorized editor intentionally submits. Keep private provider credentials in server-side secrets, require editor authorization on the server, validate and limit input, prevent duplicate requests, and handle timeouts or provider failure. Explain the data flow and cost drivers before adding a provider. Use synthetic test content and verify unauthorized requests are denied.

Replace the sample context with your own approved facts. Review Lovable’s proposed changes before accepting them.

Evidence before the next step

Check your work.

  • The data flow identifies the provider, input, output, and cost driver.
  • Private credentials never reach browser code or practice downloads.
  • Unauthorized and failed requests have safe, understandable outcomes.

Your checkmark stays in this browser. It records your own progress, not a certification.

Official sources & further reading

Reviewed November 19, 2026. Plans, terminology and interfaces can change; follow the linked documentation if your workspace differs.