Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.
This repository was archived by the owner on May 30, 2025. It is now read-only.

Next.js Static Config #20

@runia1

Description

@runia1

I have a side project written in nextjs, deployed on vercel. It has a handful of lambdas that serve as the backend (/pages/api/...), but no server.

A common pattern for feature flag solutions (launchdarkly, and others) is to have a heavy initialization on the server side, usually the initialization is fetching all the feature flag config and caching it somewhere.. in memory or in a cache. After that the feature decisions can be made locally in the sdk, which is much more performant than making an api call for each feature decision.

Unfortunately since my stack doesn't have persistent servers, a heavy initialization for each lambda invocation is not ideal. I also don't like the idea of needing to maintain infrastructure for caching such as redis or memcached. Even if I had redis that each of the lambdas could fetch the config from, I'd still need some mechanism for keeping it up to date with the latest feature config.

What if, each time the config was updated in the UI, it could just save that to a flat file.. json or whatever.. Then make a webhook call to tell Vercel to re-deploy. Part of the deploy pipeline would fetch the latest feature flag config file and bundle that with the deployment. Then the frontend & backend would both have the config baked in. No api calls necessary, no caching infrastructure to manage, no heavy initialization for lambdas or frontend. The only downside I can think of is if your CI CD pipeline took a while to re-deploy and Product managers were in the UI making feature flag changes a lot. But if your company was already doing CI CD I'd think it would be pretty fast.

I'm curious what you think about this idea? It looks like Vercel has a deployments api endpoint so you could create a Vercel Integration which could make this super easy to set up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions